Thank you for posting! Here is an outline of an effective post:
Describe your issue
- What specifically do you need help with
- Relevant context (e.g. public health trends or associated data infrastructure)
- Timeline/urgency
- (No sensitive or identifiable information)
What steps have you already taken to find an answer?
- Ensure you have searched the Epi R Handbook and internet forums like stackoverflow: https://stackoverflow.com/
# reprex1 script
# install and load packages
pacman::p_load(rio, here, janitor, tidyverse, reprex, datapasta)
# import data
data.frame(
stringsAsFactors = FALSE,
adm3_name_res = c(NA,"Mountain Rural",
"Mountain Rural","East II","West III"),
sex = c("m", "f", "f", "f", "f")
)
#> adm3_name_res sex
#> 1 <NA> m
#> 2 Mountain Rural f
#> 3 Mountain Rural f
#> 4 East II f
#> 5 West III f
# clean the surveillance data
surv_clean <- surv_raw %>%
clean_names()
#> Error: object 'surv_raw' not found
# 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
# 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
Created on 2025-06-21 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 22621)
#>
#> 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: Asia/Dhaka
#> 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.3 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
Provide an example of your R code
-
Watch this video: https://www.youtube.com/watch?v=XIc-VHFeUl8
This document is also helpful: Reprex do's and don'ts • reprex -
If pasting your code, put it in backticks so that others can easy copy/paste:
- Use single backticks to make text appear as code, like
mutate()
andfilter()
- Use 3 backticks on lines above and below a large block of text to make it appear as code
male_cases <- linelist %>% filter(gender == "male")
- Use single backticks to make text appear as code, like
Follow-up
- Thank the volunteers who try to help you
- Mark one reply as the “Solution” if appropriate