Hello,
I tried to solve this but cannot figure it out. Below is a reprex of my problem. I am expecting a ggplot bar plot but get an error saying that the data is not found.
Thanks for helping me!
# 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-06-03 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: America/Denver
#> 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.4.0 yaml_2.3.10 fastmap_1.2.0 R6_2.6.1
#> [9] generics_0.1.4 knitr_1.50 rprojroot_2.0.4 tzdb_0.5.0
#> [13] pillar_1.10.2 RColorBrewer_1.1-3 rlang_1.1.6 stringi_1.8.7
#> [17] xfun_0.52 fs_1.6.6 timechange_0.3.0 cli_3.6.5
#> [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 farver_2.1.2 pacman_0.5.1
#> [33] rmarkdown_2.29 tools_4.5.0 pkgconfig_2.0.3 htmltools_0.5.8.1