My First Training Post - Error in Generating gg bar plot (reprex)

Hello,
I tried to run this code to generate a gg bar plot, but kept getting this error as written below: Thank you in advance for your help!

# 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()
#> Error: object 'Surv_clean' not found

Created on 2025-05-18 with reprex v2.1.1

Session info

sessionInfo()
#> R version 4.5.0 (2025-04-11 ucrt)
#> Platform: x86_64-w64-mingw32/x64
#> Running under: Windows 11 x64 (build 26100)
#> 
#> Matrix products: default
#>   LAPACK version 3.12.1
#> 
#> locale:
#> [1] LC_COLLATE=English_United States.utf8 
#> [2] LC_CTYPE=English_United States.utf8   
#> [3] LC_MONETARY=English_United States.utf8
#> [4] LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.utf8    
#> 
#> time zone: Africa/Lagos
#> tzcode source: internal
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#>  [1] datapasta_3.1.0 reprex_2.1.1    lubridate_1.9.4 forcats_1.0.0  
#>  [5] stringr_1.5.1   dplyr_1.1.4     purrr_1.0.4     readr_2.1.5    
#>  [9] tidyr_1.3.1     tibble_3.2.1    ggplot2_3.5.2   tidyverse_2.0.0
#> [13] janitor_2.2.1   here_1.0.1      rio_1.2.3      
#> 
#> loaded via a namespace (and not attached):
#>  [1] gtable_0.3.6      compiler_4.5.0    tidyselect_1.2.1  snakecase_0.11.1 
#>  [5] scales_1.3.0      yaml_2.3.10       fastmap_1.2.0     R6_2.6.1         
#>  [9] generics_0.1.3    knitr_1.50        munsell_0.5.1     rprojroot_2.0.4  
#> [13] tzdb_0.5.0        pillar_1.10.2     rlang_1.1.6       stringi_1.8.7    
#> [17] xfun_0.52         fs_1.6.6          timechange_0.3.0  cli_3.6.4        
#> [21] withr_3.0.2       magrittr_2.0.3    digest_0.6.37     grid_4.5.0       
#> [25] rstudioapi_0.17.1 hms_1.1.3         lifecycle_1.0.4   vctrs_0.6.5      
#> [29] evaluate_1.0.3    glue_1.8.0        colorspace_2.1-1  pacman_0.5.1     
#> [33] rmarkdown_2.29    tools_4.5.0       pkgconfig_2.0.3   htmltools_0.5.8.1

Kia ora Stephen,

Great to see you trying things out!

R is a case sensitive language, so uppercase and lowercase letters are considered to be different. In your case, R considers surv_clean and Surv_clean to be different things. Make sure you haven’t accidentally capitalised any of your object references and that should take care of that error.