Created
May 10, 2022 07:25
-
-
Save Robinlovelace/679ddb50de714883a43735e001b3b023 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t11_raw = readxl::read_excel("nat-chil-meas-prog-eng-2020-2021-tab.xlsx", sheet = "Table 11", skip = 13) | |
t11 = t11_raw %>% | |
janitor::clean_names() | |
# names(t11) | |
names(t11)[1:2] = c("class", "year") | |
t11_most_deprived = t11 %>% | |
select(class, year, prevalence_3) %>% | |
fill(class) %>% | |
filter(str_detect(string = class, pattern = "Reception|Year")) %>% | |
slice(-c(1:2)) %>% | |
mutate(year = as.numeric(str_sub(string = year, start = 1, end = 4))) %>% | |
mutate(`IMD decile` = "Most deprived IMD decile") | |
t11_least_deprived = t11 %>% | |
select(class, year, prevalence_3 = prevalence_7) %>% | |
fill(class) %>% | |
filter(str_detect(string = class, pattern = "Reception|Year")) %>% | |
slice(-c(1:2)) %>% | |
mutate(year = as.numeric(str_sub(string = year, start = 1, end = 4))) %>% | |
mutate(`IMD decile` = "Least deprived IMD decile") | |
t11_most_least = bind_rows(t11_most_deprived, t11_least_deprived) | |
# t11$class | |
t11_most_least %>% | |
ggplot(aes(year, prevalence_3, colour = class)) + | |
geom_line() + | |
geom_vline(xintercept = 2019, colour = "grey", lty = 2) + | |
xlab("Academic year starting") + | |
ylab("% Obese") + | |
ylim(c(0, NA)) + | |
ggthemr::rotate_x_text(90) + | |
scale_x_continuous(breaks = seq(from = 2006, to = 2020, by = 2)) + | |
facet_grid(~ `IMD decile`) + | |
labs(caption = "Source: National Child Measurement Programme.\nGraph: by Robin Lovelace with the R package ggplot2") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment