Last active
February 28, 2022 17:13
-
-
Save katiefinning1/160d090251d7f85ba3bfd1b9c23cf1ef to your computer and use it in GitHub Desktop.
COVID-19 vaccination uptake over time by age and sociodemographic characteristics
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
#################################### | |
# COVID-19 Vaccination uptake over time | |
# Created by: Katie Finning | |
# R version 3.4.0 | |
#################################### | |
library(readr) | |
library(dplyr) | |
library(ggplot2) | |
# Create colour scheme to use for lines | |
# NB this is a colour-blind friendly palette | |
colour_palette <- c("#000000", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#9999CC", "#0072B2", "#D55E00", | |
"#CC79A7", "#999999") | |
# VACCINATION UPTAKE OVER TIME --------------------------------------------------------------------------------------- | |
# Load dataset | |
monthly_vaccination_rates_2021_08_provisional1 <- read_csv("monthly_vaccination_rates_2021_08_provisional1.csv") | |
View(monthly_vaccination_rates_2021_08_provisional1) | |
# Convert time to a factor variable and then re-order the levels from earliest to latest to ensure they appear in | |
# chronological order in plots (rather than default alphabetical order) | |
monthly_vaccination_rates_2021_08_provisional1 <- dplyr::mutate_at(monthly_vaccination_rates_2021_08_provisional1, | |
vars(TimePeriod), as.factor) | |
monthly_vaccination_rates_2021_08_provisional1$TimePeriod <- factor(monthly_vaccination_rates_2021_08_provisional1$TimePeriod, | |
levels = c("Dec-20", "Jan-21", "Feb-21", | |
"Mar-21", "Apr-21", "May-21", | |
"Jun-21", "Jul-21", "Aug-21")) | |
# Convert count, LCI and UCI variables to the inverse so they represent the proportion vaccinated rather than the | |
# proportion NOT vaccinated | |
monthly_vaccination_rates_2021_08_provisional1 <- monthly_vaccination_rates_2021_08_provisional1 %>% | |
dplyr::mutate(Count = Denominator-Count, Value = 100-Value, LCI = 100-LCI, UCI = 100-UCI) | |
# Filter out age-standardised estimates and focus on crude estimates | |
monthly_vaccination_rates_2021_08_provisional1 <- monthly_vaccination_rates_2021_08_provisional1 %>% | |
filter(yAxisLabel == "Crude percentage of people aged 18+ who have not received a vaccination (%)") | |
# Filter out breakdowns by region and focus on age stratification | |
monthly_vaccination_rates_2021_08_provisional1 <- monthly_vaccination_rates_2021_08_provisional1 %>% | |
filter(SubCategory == "England" |SubCategory == "18-29" | SubCategory == "30-39" | SubCategory == "40-49" | | |
SubCategory == "50-59" |SubCategory == "60-69" | SubCategory == "70-79" | SubCategory == "80+") | |
# Replace SubCategory == "England" with "All age groups" | |
monthly_vaccination_rates_2021_08_provisional1[monthly_vaccination_rates_2021_08_provisional1 == "England"] <- | |
"All age groups" | |
# UPTAKE OVER TIME BY AGE AND ETHNICITY ------------------------------------------------------------------------------ | |
# Create dataset including all months where CategoryType = Ethnic group | |
time_ethnic_age <- monthly_vaccination_rates_2021_08_provisional1 %>% | |
filter(CategoryType == "Ethnic group") | |
# Re-arrange so combined age group rows are placed at the end of other age groups, within each level of time and ethnicity | |
time_ethnic_age <- dplyr::arrange(time_ethnic_age, TimePeriod, SubCategory) | |
# Convert age group and ethnicity to factor variables and order levels | |
time_ethnic_age <- dplyr::mutate_at(time_ethnic_age, vars(Category, SubCategory), as.factor) | |
time_ethnic_age$SubCategory <- factor(time_ethnic_age$SubCategory, | |
levels = c("All age groups", "18-29", "30-39", "40-49", "50-59", | |
"60-69", "70-79", "80+")) | |
time_ethnic_age$Category <- factor(time_ethnic_age$Category, | |
levels = c("White British", "Indian", "Chinese", "Other", | |
"White other", "Bangladeshi", "Pakistani", | |
"Mixed", "Black African", "Black Caribbean")) | |
# Plot vaccination uptake over time where category = ethnicity and subcategory = age group, faceted by age group | |
ggplot(time_ethnic_age, aes(x = TimePeriod, group = Category)) + | |
geom_line(aes(y = Value, colour = Category), size = 0.8) + | |
facet_wrap(~ SubCategory, nrow = 2) + # Facet by SubCategory, in a 4x2 grid (2 rows) | |
labs(y = "Proportion of people vaccinated (%)", x = NULL, colour = "Ethnic group") + | |
theme(axis.text.x = element_text(angle = 90)) + | |
scale_colour_manual(values = colour_palette) | |
# VACCINATION UPTAKE OVER TIME BY AGE AND SEX ------------------------------------------------------------------- | |
# Create dataset including all months where CategoryType = Sex | |
time_sex_age <- monthly_vaccination_rates_2021_08_provisional1 %>% | |
filter(CategoryType == "Sex") | |
# Re-arrange so combined age group rows are placed at the end of other age groups, within each level of time and ethnicity | |
time_sex_age <- dplyr::arrange(time_sex_age, TimePeriod, SubCategory) | |
# Convert age group and sex to factor variables and order levels | |
time_sex_age <- dplyr::mutate_at(time_sex_age, vars(Category, SubCategory), as.factor) | |
time_sex_age$SubCategory <- factor(time_sex_age$SubCategory, | |
levels = c("All age groups", "18-29", "30-39", "40-49", "50-59", | |
"60-69", "70-79", "80+")) | |
time_sex_age$Category <- factor(time_sex_age$Category, levels = c("Female", "Male")) | |
# Plot vaccination uptake over time by sex and age group, faceted by age group | |
ggplot(time_sex_age, aes(x = TimePeriod, group = Category)) + | |
geom_line(aes(y = Value, colour = Category), size = 0.8) + | |
facet_wrap(~ SubCategory, nrow = 2) + # Facet by SubCategory, in a 4x2 grid (2 rows)) + | |
labs(y = "Proportion of people vaccinated (%)", x = NULL, colour = "Sex") + | |
theme(axis.text.x = element_text(angle = 90)) + | |
scale_colour_brewer(palette = "Set2") | |
# UPTAKE OVER TIME BY AGE AND DISABILITY STATUS ----------------------------------------------------------------------- | |
# Create dataset including all months where CategoryType = Disability status | |
time_disability_age <- monthly_vaccination_rates_2021_08_provisional1 %>% | |
filter(CategoryType == "Disability status") | |
# Re-arrange so combined age group rows are placed at the end of other age groups, within each level of time and ethnicity | |
time_disability_age <- dplyr::arrange(time_disability_age, TimePeriod, SubCategory) | |
# Convert age group and sex to factor variables and order levels | |
time_disability_age <- dplyr::mutate_at(time_disability_age, vars(Category, SubCategory), as.factor) | |
time_disability_age$SubCategory <- factor(time_disability_age$SubCategory, | |
levels = c("All age groups", "18-29", "30-39", "40-49", "50-59", | |
"60-69", "70-79", "80+")) | |
time_disability_age$Category <- factor(time_disability_age$Category, levels = c("Not Limited", "Limited a little", | |
"Limited a lot")) | |
# Plot vaccination uptake over time by disability and age group, faceted by age group | |
ggplot(time_disability_age, aes(x = TimePeriod, group = Category)) + | |
geom_line(aes(y = Value, colour = Category), size = 0.8) + | |
facet_wrap(~ SubCategory, nrow = 2) + # Facet by SubCategory, in a 4x2 grid (2 rows)) + | |
labs(y = "Proportion of people vaccinated (%)", x = NULL, colour = "Disability status") + | |
theme(axis.text.x = element_text(angle = 90)) + | |
scale_colour_brewer(palette = "Set2") | |
# UPTAKE OVER TIME BY AGE AND RELIGION -------------------------------------------------------------------------------- | |
# Create dataset including all months where CategoryType = Ethnic group | |
time_religion_age <- monthly_vaccination_rates_2021_08_provisional1 %>% | |
filter(CategoryType == "Religion") | |
# Re-arrange so combined age group rows are placed at the end of other age groups, within each level of time and religion | |
time_religion_age <- dplyr::arrange(time_religion_age, TimePeriod, SubCategory) | |
# Convert age group and religion to factor variables and order levels | |
time_religion_age <- dplyr::mutate_at(time_religion_age, vars(Category, SubCategory), as.factor) | |
time_religion_age$SubCategory <- factor(time_religion_age$SubCategory, | |
levels = c("All age groups", "18-29", "30-39", "40-49", "50-59", | |
"60-69", "70-79", "80+")) | |
time_religion_age$Category <- factor(time_religion_age$Category, | |
levels = c("Christian", "Hindu", "Jewish", | |
"Sikh", "Religion Not Stated", | |
"No religion", "Other Religion", | |
"Buddhist", "Muslim")) | |
# Plot vaccination uptake over time where category = religion and subcategory = age group, faceted by age group | |
ggplot(time_religion_age, aes(x = TimePeriod, group = Category)) + | |
geom_line(aes(y = Value, colour = Category), size = 0.8) + | |
facet_wrap(~ SubCategory, nrow = 2) + # Facet by SubCategory, in a 4x2 grid (2 rows) | |
labs(y = "Proportion of people vaccinated (%)", x = NULL, colour = "Religion") + | |
theme(axis.text.x = element_text(angle = 90)) + | |
scale_colour_manual(values = colour_palette) | |
# UPTAKE OVER TIME BY AGE AND IMD QUINTILE ---------------------------------------------------------------------------- | |
# Create dataset including all months where CategoryType = IMD quintile | |
time_deprivation_age <- monthly_vaccination_rates_2021_08_provisional1 %>% | |
filter(CategoryType == "Deprivation quintile") | |
# Re-arrange so combined age group rows are placed at the end of other age groups, within each level of time and IMD | |
time_deprivation_age <- dplyr::arrange(time_deprivation_age, TimePeriod, SubCategory) | |
# Convert age group and IMD to factor variables and order levels | |
time_deprivation_age <- dplyr::mutate_at(time_deprivation_age, vars(Category, SubCategory), as.factor) | |
time_deprivation_age$SubCategory <- factor(time_deprivation_age$SubCategory, | |
levels = c("All age groups", "18-29", "30-39", "40-49", "50-59", | |
"60-69", "70-79", "80+")) | |
# Plot vaccination uptake over time by IMD quintile and age group, faceted by age | |
ggplot(time_deprivation_age, aes(x = TimePeriod, group = Category)) + | |
geom_line(aes(y = Value, colour = Category), size = 0.8) + | |
facet_wrap(~ SubCategory, nrow = 2) + | |
labs(y = "Proportion of people vaccinated (%)", x = NULL, colour = "Deprivation quintile") + | |
theme(axis.text.x = element_text(angle = 90)) + | |
scale_colour_manual(values = c("#E69F00", "#009E73", "#CC79A7", "#D55E00", "#56B4E9")) | |
# UPTAKE OVER TIME BY AGE AND ENGLISH LANGUAGE PROFICIENCY ------------------------------------------------------------ | |
# Create dataset including all months where CategoryType = English language proficiency | |
time_language_age <- monthly_vaccination_rates_2021_08_provisional1 %>% | |
filter(CategoryType == "English language proficiency") | |
# Re-arrange so combined age group rows are placed at the end of other age groups, within each level of time and English proficiency | |
time_language_age <- dplyr::arrange(time_language_age, TimePeriod, SubCategory) | |
# Convert age group and language to factor variables and order levels | |
time_language_age <- dplyr::mutate_at(time_language_age, vars(Category, SubCategory), as.factor) | |
time_language_age$SubCategory <- factor(time_language_age$SubCategory, | |
levels = c("All age groups", "18-29", "30-39", "40-49", "50-59", | |
"60-69", "70-79", "80+")) | |
time_language_age$Category <- factor(time_language_age$Category, | |
levels = c("Main language", "Not main language")) | |
# Plot vaccination uptake over time where category = English proficiency and subcategory = age group, faceted by age group | |
ggplot(time_language_age, aes(x = TimePeriod, group = Category)) + | |
geom_line(aes(y = Value, colour = Category), size = 0.8) + | |
facet_wrap(~ SubCategory, nrow = 2) + # Facet by SubCategory, in a 4x2 grid (2 rows) | |
labs(y = "Proportion of people vaccinated (%)", x = NULL, colour = "English language proficiency") + | |
theme(axis.text.x = element_text(angle = 90)) + | |
scale_colour_brewer(palette = "Set2") | |
# UPTAKE OVER TIME BY AGE AND EDUCATIONAL ATTAINMENT ------------------------------------------------------------------- | |
# Create dataset including all months where CategoryType = educational attainment | |
time_attainment_age <- monthly_vaccination_rates_2021_08_provisional1 %>% | |
filter(CategoryType == "Educational attainment") | |
# Re-arrange so combined age group rows are placed at the end of other age groups, within each level of time and attainment | |
time_attainment_age <- dplyr::arrange(time_attainment_age, TimePeriod, SubCategory) | |
# Convert age group and language to factor variables and order levels | |
time_attainment_age <- dplyr::mutate_at(time_attainment_age, vars(Category, SubCategory), as.factor) | |
time_attainment_age$SubCategory <- factor(time_attainment_age$SubCategory, | |
levels = c("All age groups","30-39", "40-49", "50-59", | |
"60-69", "70-79", "80+")) | |
time_attainment_age$Category <- factor(time_attainment_age$Category, | |
levels = c("Apprenticeship", "Level 4+", "Level 3", "Level 2", | |
"Level 1", "Other", "No qualification")) | |
# Plot vaccination uptake over time where category = attainment and subcategory = age group, faceted by age group | |
ggplot(time_attainment_age, aes(x = TimePeriod, group = Category)) + | |
geom_line(aes(y = Value, colour = Category), size = 0.8) + | |
facet_wrap(~ SubCategory, nrow = 2, scales = "free") + # Facet by SubCategory, in a 4x2 grid (2 rows) | |
labs(y = "Proportion of people vaccinated (%)", x = NULL, colour = "Educational attainment") + | |
theme(axis.text.x = element_text(angle = 90)) + | |
scale_colour_manual(values = colour_palette) | |
# UPTAKE OVER TIME BY NATIONAL STATISTICS SOCIO-ECONOMIC CLASSIFICATION (NS-SEC) AND AGE ----------------------------------------------- | |
# Create dataset including all months where CategoryType = NS-SEC | |
time_nssec_age <- monthly_vaccination_rates_2021_08_provisional1 %>% | |
filter(CategoryType == "National Statistics Socio-economic classification") | |
# Re-arrange so combined age group rows are placed at the end of other age groups, within each level of time and NS-SEC | |
time_nssec_age <- dplyr::arrange(time_nssec_age, TimePeriod, SubCategory) | |
# Recode NS-SEC categories to just numbers to keep the legend in the plot simple; can add subtext will full descriptions | |
time_nssec_age <- time_nssec_age %>% | |
mutate(Category = recode(time_nssec_age$Category, "1 Higher managerial, administrative and professional occupations" = "1", | |
"2 Lower managerial, administrative and professional occupations" = "2", | |
"3 Intermediate occupations" = "3", "4 Small employers and own account workers" = "4", | |
"5 Lower supervisory and technical occupations" = "5", | |
"6 Semi-routine occupations" = "6", "7 Routine occupations" = "7", | |
"8 Never worked and long-term unemployed" = "8")) | |
# Convert age group and NS-SEC to factor variables and order levels | |
time_nssec_age <- dplyr::mutate_at(time_nssec_age, vars(Category, SubCategory), as.factor) | |
time_nssec_age$SubCategory <- factor(time_nssec_age$SubCategory, | |
levels = c("All age groups", "18-29", "30-39", "40-49", "50-59", | |
"60-69", "70-79", "80+")) | |
time_nssec_age$Category <- factor(time_nssec_age$Category, | |
levels = c("1", "2", "3", "4", "5", "6", "7", "8", | |
"Not classified")) | |
# Plot vaccination uptake over time where category = NS-SEC and subcategory = age group, faceted by age group | |
ggplot(time_nssec_age, aes(x = TimePeriod, group = Category)) + | |
geom_line(aes(y = Value, colour = Category), size = 0.8) + | |
facet_wrap(~ SubCategory, nrow = 2) + # Facet by SubCategory, in a 4x2 grid (2 rows) | |
labs(y = "Proportion of people vaccinated (%)", x = NULL, colour = "NS-SEC") + | |
theme(axis.text.x = element_text(angle = 90)) + | |
scale_colour_manual(values = colour_palette) | |
# UPTAKE OVER TIME BY HOUSEHOLD TENURE AND AGE --------------------------------------------------------------------------------------- | |
# Create dataset including all months where CategoryType = household tenure | |
time_tenure_age <- monthly_vaccination_rates_2021_08_provisional1 %>% | |
filter(CategoryType == "Household tenure") | |
# Re-arrange so combined age group rows are placed at the end of other age groups, within each level of time and tenure | |
time_tenure_age <- dplyr::arrange(time_tenure_age, TimePeriod, SubCategory) | |
# Convert age group and household tenure to factor variables and order levels | |
time_tenure_age <- dplyr::mutate_at(time_tenure_age, vars(Category, SubCategory), as.factor) | |
time_tenure_age$SubCategory <- factor(time_tenure_age$SubCategory, | |
levels = c("All age groups", "18-29", "30-39", "40-49", "50-59", | |
"60-69", "70-79", "80+")) | |
time_tenure_age$Category <- factor(time_tenure_age$Category, | |
levels = c("Owned", "Private rented", "Social rented", "Other", "Not classified")) | |
# Plot vaccination uptake over time where category = tenure and subcategory = age group, faceted by age group | |
ggplot(time_tenure_age, aes(x = TimePeriod, group = Category)) + | |
geom_line(aes(y = Value, colour = Category), size = 0.8) + | |
facet_wrap(~ SubCategory, nrow = 2) + # Facet by SubCategory, in a 4x2 grid (2 rows) | |
labs(y = "Proportion of people vaccinated (%)", x = NULL, colour = "Household tenure") + | |
theme(axis.text.x = element_text(angle = 90)) + | |
scale_colour_manual(values = colour_palette) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment