I'm trying to plot lines for men and women against their year of birth (labelled birthy) on the same graph, using the dataframe below
df <- data.frame(birthy=c("1881-1890","1960-1962","2016-2018"),
Men=c(76.1, 77.5, 84.9),
Women=c(77.3, 80.7, 87.6))
I tried the following code in ggplot2
ggplot(df, aes(birthy)) +
geom_line(aes(y = Men, colour = "Men")) +
geom_line(aes(y = Women, colour = "Women"))
and R throws the following error
geom_path: Each group consists of only one observation. Do you need to adjust
the group aesthetic?
I'm looking for a way to fix this error. Any help is well appreciated!