Hi,
covid_age.pdf (47.4 KB)
I am trying to draw age pyramid in R. But not quite successful. Please see below the reprex. Error message is saying that the object "covid_age" is not found, but I have uploaded the data correctly. Please see the attached data.
I appreciate your help.
library(tidyverse)
#> Warning: package 'tidyverse' was built under R version 4.0.2
library(ggpol)
#> Warning: package 'ggpol' was built under R version 4.0.2
library(ggplot2)
co1<-ggplot(data=covid_age, aes(x = age, y =cfr, fill =sex)) +
geom_bar(stat = "identity") +
facet_share(~sex, dir = "h", scales = "free", reverse_num = TRUE) + # note: scales = "free"
coord_flip() +
theme_minimal() +
labs(y = "Count", x = "Age Band", title = " ") +
scale_fill_manual(values = c("pink", "blue"))
#> Error in ggplot(data = covid_age, aes(x = age, y = all_cases, fill = sex)): object 'covid_age' not found
co1
#> Error in eval(expr, envir, enclos): object 'co1' not found