This is a practice upload using reprex! I am trying to create an epi curve but there is an error with my x aesthetic.
# load packages
pacman::p_load(rio, janitor, tidyverse, here, datapasta)
# the data
demo_data<-data.frame(
stringsAsFactors = FALSE,
check.names = FALSE,
case_id = c("694928", "86340d", "92d002", "544bd1", "6056ba"),
`onset date` = c("11/9/2014","10/30/2014",
"8/16/2014","8/29/2014","10/20/2014")
)
# epi curve
ggplot(data = demo_data, mapping = aes(x = `onset date`))+
geom_histogram()
#> Error in `geom_histogram()`:
#> ! Problem while computing stat.
#> βΉ Error occurred in the 1st layer.
#> Caused by error in `setup_params()`:
#> ! `stat_bin()` requires a continuous x aesthetic
#> β the x aesthetic is discrete.
#> βΉ Perhaps you want `stat="count"`?
#> Backtrace:
#> β
#> 1. ββbase::tryCatch(...)
#> 2. β ββbase (local) tryCatchList(expr, classes, parentenv, handlers)
#> 3. β ββbase (local) tryCatchOne(...)
#> 4. β β ββbase (local) doTryCatch(return(expr), name, parentenv, handler)
#> 5. β ββbase (local) tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
#> 6. β ββbase (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 7. β ββbase (local) doTryCatch(return(expr), name, parentenv, handler)
#> 8. ββbase::withCallingHandlers(...)
#> 9. ββbase::saveRDS(...)
#> 10. ββbase::do.call(...)
#> 11. ββbase (local) `<fn>`(...)
#> 12. ββglobal `<fn>`(input = base::quote("choky-barb_reprex.R"))
#> 13. ββrmarkdown::render(input, quiet = TRUE, envir = globalenv(), encoding = "UTF-8")
#> 14. ββknitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
#> 15. ββknitr:::process_file(text, output)
#> 16. ββknitr:::handle_error(...)
#> 17. β ββbase::withCallingHandlers(...)
#> 18. ββbase::withCallingHandlers(...)
#> 19. ββknitr:::process_group(group)
#> 20. ββknitr:::process_group.block(group)
#> 21. ββknitr:::call_block(x)
#> 22. ββknitr:::block_exec(params)
#> 23. ββknitr:::eng_r(options)
#> 24. ββknitr:::in_input_dir(...)
#> 25. β ββknitr:::in_dir(input_dir(), expr)
#> 26. ββknitr (local) evaluate(...)
#> 27. ββevaluate::evaluate(...)
#> 28. ββevaluate:::evaluate_call(...)
#> 29. ββevaluate (local) handle(...)
#> 30. β ββbase::try(f, silent = TRUE)
#> 31. β ββbase::tryCatch(...)
#> 32. β ββbase (local) tryCatchList(expr, classes, parentenv, handlers)
#> 33. β ββbase (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 34. β ββbase (local) doTryCatch(return(expr), name, parentenv, handler)
#> 35. ββbase::withCallingHandlers(...)
#> 36. ββbase::withVisible(value_fun(ev$value, ev$visible))
#> 37. ββknitr (local) value_fun(ev$value, ev$visible)
#> 38. ββknitr (local) fun(x, options = options)
#> 39. ββbase::withVisible(knit_print(x, ...))
#> 40. ββknitr::knit_print(x, ...)
#> 41. ββknitr:::knit_print.default(x, ...)
#> 42. ββevaluate (local) normal_print(x)
#> 43. ββbase::print(x)
#> 44. ββggplot2:::print.ggplot(x)
#> 45. ββggplot2::ggplot_build(x)
#> 46. ββggplot2:::ggplot_build.ggplot(x)
#> 47. ββggplot2:::by_layer(...)
#> 48. ββrlang::try_fetch(...)
#> 49. β ββbase::tryCatch(...)
#> 50. β β ββbase (local) tryCatchList(expr, classes, parentenv, handlers)
#> 51. β β ββbase (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 52. β β ββbase (local) doTryCatch(return(expr), name, parentenv, handler)
#> 53. β ββbase::withCallingHandlers(...)
#> 54. ββggplot2 (local) f(l = layers[[i]], d = data[[i]])
#> 55. ββl$compute_statistic(d, layout)
#> 56. ββggplot2 (local) compute_statistic(..., self = self)
#> 57. ββself$stat$setup_params(data, self$stat_params)
#> 58. ββggplot2 (local) setup_params(..., self = self)
#> 59. ββcli::cli_abort(...)
#> 60. ββrlang::abort(...)
Created on 2024-03-04 with reprex v2.0.2
Session info
sessionInfo()
#> R version 4.3.2 (2023-10-31 ucrt)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19045)
#>
#> Matrix products: default
#>
#>
#> locale:
#> [1] LC_COLLATE=English_United Kingdom.utf8
#> [2] LC_CTYPE=English_United Kingdom.utf8
#> [3] LC_MONETARY=English_United Kingdom.utf8
#> [4] LC_NUMERIC=C
#> [5] LC_TIME=English_United Kingdom.utf8
#>
#> time zone: Europe/London
#> tzcode source: internal
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] datapasta_3.1.0 here_1.0.1 lubridate_1.9.3 forcats_1.0.0
#> [5] stringr_1.5.0 dplyr_1.1.3 purrr_1.0.2 readr_2.1.4
#> [9] tidyr_1.3.0 tibble_3.2.1 ggplot2_3.4.4 tidyverse_2.0.0
#> [13] janitor_2.2.0 rio_1.0.1
#>
#> loaded via a namespace (and not attached):
#> [1] styler_1.10.2 utf8_1.2.4 generics_0.1.3 stringi_1.7.12
#> [5] hms_1.1.3 digest_0.6.33 magrittr_2.0.3 evaluate_0.22
#> [9] grid_4.3.2 timechange_0.2.0 fastmap_1.1.1 rprojroot_2.0.4
#> [13] R.oo_1.26.0 R.cache_0.16.0 R.utils_2.12.3 fansi_1.0.5
#> [17] scales_1.2.1 cli_3.6.1 rlang_1.1.1 R.methodsS3_1.8.2
#> [21] munsell_0.5.0 reprex_2.0.2 withr_2.5.2 yaml_2.3.7
#> [25] tools_4.3.2 tzdb_0.4.0 colorspace_2.1-0 pacman_0.5.1
#> [29] vctrs_0.6.4 R6_2.5.1 lifecycle_1.0.3 snakecase_0.11.1
#> [33] fs_1.6.3 pkgconfig_2.0.3 pillar_1.9.0 gtable_0.3.4
#> [37] glue_1.6.2 xfun_0.40 tidyselect_1.2.0 rstudioapi_0.15.0
#> [41] knitr_1.45 htmltools_0.5.7 rmarkdown_2.25 compiler_4.3.2