I am learning a bit of ggplot.
I know I have to tidy my data.
Here in the example, I want to plot two lines with geom_line. The lines should be: unemploy and pasavert.
As you will see on the plot, pasvert doesn't show any info. Its just a flat line.
On excel, "you can adjust the secondary axis labels to the range of pasvert".
economics_tidy <- economics %>% select(date, unemploy, psavert) %>% pivot_longer(cols = c(unemploy, psavert), names_to = "variable", values_to = "value") ggplot(economics_tidy, aes(x = date, y = value, color = variable)) + geom_line() + scale_x_date(date_labels = "%Y-%m") + scale_y_continuous(name = "unemploy", sec.axis = sec_axis(~. * 15, name = "psavert"))+ labs(title = "Ejemplo de gráfico con eje secundario", x = "Fecha", y = "Valor")
No matter what I do in scale_y_continuos, in especific inside of:
I am just changing the labels of the secondary axis, but in no way scaling the data to plot.
Is it possible to do that on tidy data?
Or I need to separate the columns in unemploy and pasavert?
I can't find infor about this issue.
As always, thanks four time and interest.