Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
110 changes: 110 additions & 0 deletions Manjari SHANKAR_Coverage Task.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
---
title: "Coverage_Task"
author: "Manjari Shankar"
date: "2023-10-04"
output:
prettydoc::html_pretty:
theme: cayman
highlight: github
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Load packages

```{r message=FALSE, warning=FALSE, include=FALSE}
pacman::p_load(
here, # relative file pathways
janitor, # data cleaning and tables
lubridate, # working with dates
tidyverse, # data management and visualization
readxl, # read Excel files
stringr, # working with strings
plotly, # interactive graphs
ggplot2, # plotting and visualizing the data
gganimate, # animate ggplot
scales, # formatting as percentages
flextable # tabular presentation
)
```

## Import datasets

```{r include=FALSE}
green_blue_fever_raw <- read_xlsx("data_20240120.xlsx", sheet = "Data1", skip = 2)
pink_fever_raw <- read_xlsx("pink_fever_monthly.xlsx")
```

## Review & Data cleaning

```{r include=FALSE}
skimr::skim(pink_fever_raw) # checking variable summaries and types
skimr::skim(green_blue_fever_raw)

green_blue_fever <- green_blue_fever_raw %>%
janitor:: clean_names() %>% # dataset had names with spaces
mutate(bluefever_coverage = bf_coverage * 100,
date = as.Date(date)) %>% # date originally a character variable
rename(greenfever_coverage = gf_coverage) %>%
select(date, bluefever_coverage, greenfever_coverage)


pink_fever <- pink_fever_raw %>%
rename(pinkfever_coverage = coverage) %>% # aligning coverage column naming with other dataset
mutate(date = make_date(year = year, month = month, day = day)) %>% # adding in date column to align datasets
select(date, pinkfever_coverage)

```

## Combining datasets

```{r message=FALSE, warning=FALSE, include=FALSE}
combined_coverage <- full_join(green_blue_fever, pink_fever, by = c("date" = "date"))

combined_coverage2 <- combined_coverage %>%
pivot_longer(
cols = -date,
names_to = "vaccine",
values_to = "vaccination_coverage"
) %>%
drop_na()
```

## Summary by Vaccine

```{r echo=FALSE}
combined_overview <- combined_coverage2 %>%
group_by(vaccine) %>%
summarise(Vax_Introduced = first(date), Vax_Last = last(date), pct_change = percent((last(vaccination_coverage)- first(vaccination_coverage))/first(vaccination_coverage)))

qflextable(combined_overview) %>%
theme_booktabs() # shows first and last date of administration and % change since introduction
```

## Plotting the data

```{r echo=FALSE, message=FALSE, warning=FALSE}

coverage_plot <- combined_coverage2 %>%
ggplot() +
aes(x = date, y = vaccination_coverage, colour = vaccine) +
geom_line(size = 0.8) +
scale_x_date(date_breaks = "2 year", date_labels = "%b-%Y", limit=c(as.Date("2000-04-01"),as.Date("2022-12-09"))) +
scale_color_hue(direction = 1) +
labs(x = "Year", y = "Vaccination Coverage (%)", title = "Vaccination Coverage by Disease",
subtitle = "(Apr-2000:Dec-2022)", color = "Disease") +
theme_grey() +
theme(plot.title = element_text(face = "bold",
hjust = 0.5), plot.subtitle = element_text(hjust = 0.5),
axis.text.x=element_text(angle=90, hjust=0.5)) +
ylim(0, 100)

coverage_plot
```

```{r echo=FALSE, message=FALSE, warning=FALSE}
coverage_plot +
transition_reveal(date) # attempt at animated ggplot
```
170 changes: 170 additions & 0 deletions Manjari-SHANKAR_Coverage-Task.html

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions manjari_coverage_task.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX