Reprex example 1 - new R user

Hi everyone. I’m new to R.
My script does not work and I can’t found the issue.

# reprex1 script

# 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 surveillance data -------------------------------------------------
surv_clean surv_raw %>%
clean_names()

# make horizontal bar plot of cases per district, filled by sex -----------
ggplot(
data = Surv_clean,
mapping = aes(y = adm3_name_res, fill = sex))+
geom_bar()

#> Error: object ‘Surv_clean’ not found

Thank you in advance for your help.

1 Like

Hello,

R is case sensitive, you defined your clean data as surv_clean but then called Surv_clean in ggplot.

All the best,

Tim