reconhub / incidence

☣:chart_with_upwards_trend::chart_with_downwards_trend:☣ Compute and visualise incidence
https://reconhub.github.io/incidence
Other
58 stars 13 forks source link

Strange graphical output for simple epicurve #119

Closed gfspiteri closed 4 years ago

gfspiteri commented 4 years ago

I have been producing simple epicurves for the outbreak of COVID-19. Last Friday my outputs started acting weirdly with data not being plotted and the x-axis disappearing (I don't know that I changed anything/installed any new packages/upgraded anything etc). I tried using simple examples from the incidence package help file and again got very strange outputs. For example:

library(outbreaks)
library(ggplot2)
library(incidence)
dat <- ebola_sim$linelist$date_of_onset
i <- incidence(dat)
plot(i)

leads to

image

This is my sessionInfo() output:

R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] incidence_1.7.0 ggplot2_3.3.0   outbreaks_1.5.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3       rstudioapi_0.11  magrittr_1.5     tidyselect_1.0.0 munsell_0.5.0    colorspace_1.4-1
 [7] R6_2.4.1         rlang_0.4.5      dplyr_0.8.5      tools_3.6.3      grid_3.6.3       gtable_0.3.0    
[13] withr_2.1.2      yaml_2.2.1       assertthat_0.2.1 digest_0.6.25    tibble_2.1.3     lifecycle_0.2.0 
[19] crayon_1.3.4     purrr_0.3.3      farver_2.0.3     glue_1.3.1       labeling_0.3     compiler_3.6.3  
[25] pillar_1.4.3     aweek_1.0.0      scales_1.1.0     pkgconfig_2.0.3 

Any help appreciated!

thibautjombart commented 4 years ago

Thanks for the report. It is very weird. I'll try and see if I can reproduce it with the latest version of R.

thibautjombart commented 4 years ago

I can confirm the issue on:

> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS

Matrix products: default
BLAS:   /usr/local/lib/R/lib/libRblas.so
LAPACK: /usr/local/lib/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] incidence_1.7.0 ggplot2_3.3.0   outbreaks_1.5.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3       digest_0.6.25    withr_2.1.2      assertthat_0.2.1
 [5] crayon_1.3.4     dplyr_0.8.5      grid_3.6.3       R6_2.4.1        
 [9] lifecycle_0.2.0  gtable_0.3.0     magrittr_1.5     scales_1.1.0    
[13] pillar_1.4.3     rlang_0.4.5      farver_2.0.3     labeling_0.3    
[17] glue_1.3.1       purrr_0.3.3      munsell_0.5.0    compiler_3.6.3  
[21] pkgconfig_2.0.3  colorspace_1.4-1 tidyselect_1.0.0 tibble_2.1.3    
> 

Will address today.

thibautjombart commented 4 years ago

This looks like some buggish behaviour of ggplot2::aes_string. Working on a workaround

thibautjombart commented 4 years ago

Now reported the bug to the Rstudio crew: https://github.com/tidyverse/ggplot2/issues/3873

thibautjombart commented 4 years ago

@gfspiteri can you try installing this patch:

remotes::install_github("reconhub/incidence@issue_119")

And let me know if it fixes your issue?

gfspiteri commented 4 years ago

Thanks yes works well both for the ebola data and my script.

thibautjombart commented 4 years ago

Great, thanks. I have submitted a PR. This will be in the next release on CRAN, hopefully soon as this is a major bug. Thanks for reporting it!

gfspiteri commented 4 years ago

Thanks for responding so quickly!

thibautjombart commented 4 years ago

Reopening because the problem still exist on master, until the PR goes through