library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.6
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.1 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.2.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggplot2)
#Now we make a pie chart
Assignment2 <- read_csv("Assignment2.csv")
## Rows: 1000000 Columns: 22
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (7): Country, Disease Name, Disease Category, Age Group, Gender, Treatm...
## dbl (15): Year, Prevalence Rate (%), Incidence Rate (%), Mortality Rate (%),...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
pie_data <- Assignment2 %>%
group_by(`Disease Category`) %>%
summarize(avg_prevalence = mean(`Prevalence Rate (%)`, na.rm = TRUE))
#Now for the pie chart
ggplot(pie_data, aes(x = "", y = avg_prevalence, fill = `Disease Category`))+
geom_col(width = 1) +
coord_polar(theta = "y") +
labs(title = "Average Prevalence Rate by Disease Category") +
theme_minimal() +
theme(axis.title = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank())
