Hi,
I am trying to make a line plot that shows the overall proportion of srh scores >1, and that for male and female sex separately as well. So, there will be three lines for each year point, overall, male, and female. I could make the plot for overall and for the two sexes, but I am not being able to combine them in the same plot.
I'd greatly appreciate if you could give me an idea about it. Below are the data and the codes:
ff %>% select(srh, year, sex)%>% filter(!is.na(srh)) %>%
filter(!is.na(sex)) %>%
group_by(year) %>% # Group by year only
summarize(prop_srh = sum(srh > 1, na.rm = TRUE) / n()) %>%
ggplot(aes(x = year, y = (prop_srh * 100)/100)) +
geom_line(color = "black")
srh year sex
1 3 2017 2
2 2 2018 2
3 2 2018 2
4 3 2018 1
5 1 2017 2
6 3 2019 1
7 2 2022 1
8 2 2018 2
9 2 2018 1
10 3 2017 2
11 2 2018 1
12 3 2018 2
13 3 2020 2
14 3 2018 2
15 2 2020 2