Second Reprex Post

Kindly assist to review this code as I keep getting the following error. I tried to generate an histogram plot but I keep getting same error message. Thank you.

####################
# Example analysis 2       
####################

# install and load packages
pacman::p_load(rio, here, janitor, tidyverse, reprex, datapasta)

# import data
surv_raw <- data.frame(
  row_num = c(1L, 2L, 3L, 4L, 5L),
  onset_date = c(NA, NA, NA, NA, NA),
  age = c(23L, 1L, 16L, 10L, 0L)
)
# try to convert column to class "Date"
surv_clean <- surv_raw %>% 
  clean_names() %>% 
  mutate(onset_date = ymd(onset_date))  

# epicurve
ggplot(data = surv_clean,
       mapping = aes(x = onset_date))+
  geom_histogram()
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 5 rows containing non-finite outside the scale range
#> (`stat_bin()`).

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] generics_0.1.3    xml2_1.3.8        stringi_1.8.7     hms_1.1.3        
#>  [5] digest_0.6.37     magrittr_2.0.3    evaluate_1.0.3    grid_4.5.0       
#>  [9] timechange_0.3.0  fastmap_1.2.0     rprojroot_2.0.4   scales_1.3.0     
#> [13] cli_3.6.4         rlang_1.1.6       munsell_0.5.1     withr_3.0.2      
#> [17] yaml_2.3.10       tools_4.5.0       tzdb_0.5.0        colorspace_2.1-1 
#> [21] pacman_0.5.1      curl_6.2.2        vctrs_0.6.5       R6_2.6.1         
#> [25] lifecycle_1.0.4   snakecase_0.11.1  fs_1.6.6          pkgconfig_2.0.3  
#> [29] pillar_1.10.2     gtable_0.3.6      glue_1.8.0        xfun_0.52        
#> [33] tidyselect_1.2.1  rstudioapi_0.17.1 knitr_1.50        htmltools_0.5.8.1
#> [37] rmarkdown_2.29    compiler_4.5.0

Hi @stephen.ohuneni,

You are likely getting a blank plot because all the onset_date values (which you are trying to plot) are NA.
If you enter x = age the ggplot histogram should work.