# install and load packages
pacman::p_load(rio, here, janitor, tidyverse, reprex, datapasta)
# import data
surv_raw <- data.frame(
stringsAsFactors = FALSE,
adm3_name_res = c(NA,"Mountain Rural",
"Mountain Rural","East II","West III"),
sex = c("m", "f", "f", "f", "f")
)
# clean the surveillance data
surv_clean <- surv_raw %>%
clean_names()
# make a horizontal bar plot of cases per district, filled by sex
ggplot(
data = Surv_clean,
mapping = aes(y = adm3_name_res, fill = sex))+
geom_bar()
# make the minimal dataset
#surv_raw %>%
# head(5) %>% # take the top 5 rows only
# select(adm3_name_res, sex) %>% # keep only the relevant columns
# dpasta() # convert to stand-alone R code
“Error: object ‘Surv_clean’ not found” when creating the bar plot.
However, I have seen that “S” in ‘Surv_clean’ should be in lower caps for it to work