mjskay / tidybayes

Bayesian analysis + tidy data + geoms (R package)
http://mjskay.github.io/tidybayes
GNU General Public License v3.0
725 stars 59 forks source link

Fix internal usage of `unnest` due to changes in dev version of `tidyr` #182

Closed jamesrrae closed 5 years ago

jamesrrae commented 5 years ago

I'm getting some unusual warnings when using point_interval. For example, this code throws a warning:

data.frame(x = rnorm(1000)) %>% median_qi(x, .width = c(.50, .80, .95))

I do get the correct result but I also get a warning:

# A tibble: 3 x 6
        x .lower .upper .width .point .interval
    <dbl>  <dbl>  <dbl>  <dbl> <chr>  <chr>    
1 -0.0397 -0.734  0.634   0.5  median qi       
2 -0.0397 -1.37   1.29    0.8  median qi       
3 -0.0397 -1.91   1.97    0.95 median qi       
Warning messages:
1: unnest() has a new interface. See ?unnest for details.
Try `cols = c(.lower, .upper)`, with `mutate()` needed 
2: unnest() has a new interface. See ?unnest for details.
Try `cols = c(.lower, .upper)`, with `mutate()` needed 
3: unnest() has a new interface. See ?unnest for details.
Try `cols = c(.lower, .upper)`, with `mutate()` needed 

However, I don't get the same error message when trying other examples:

data.frame( x = rnorm(1000), y = rnorm(1000, mean = 2, sd = 2) ) %>% median_qi(x, y)

          x   x.lower  x.upper        y   y.lower  y.upper .width
1 0.02583856 -1.991302 1.972094 2.019791 -1.899487 6.062694   0.95
  .point .interval
1 median        qi

I'd like to understand why I'm getting different results. Here is my session info:

sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

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

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

other attached packages:
 [1] forcats_0.3.0      stringr_1.4.0      dplyr_0.8.3       
 [4] purrr_0.3.2        readr_1.3.1        tidyr_0.8.3.9000  
 [7] tibble_2.1.3       ggplot2_3.2.0.9000 tidyverse_1.2.1   
[10] tidybayes_1.1.0   

loaded via a namespace (and not attached):
  [1] colorspace_1.3-2          ellipsis_0.2.0.1         
  [3] ggridges_0.5.1            brms_2.7.2               
  [5] rsconnect_0.8.8           rprojroot_1.3-2          
  [7] ggstance_0.3.1            markdown_1.0             
  [9] base64enc_0.1-3           rstudioapi_0.8           
 [11] rstan_2.18.1              svUnit_0.7-12            
 [13] DT_0.4                    fansi_0.4.0              
 [15] mvtnorm_1.0-8             lubridate_1.7.4          
 [17] xml2_1.2.0                bridgesampling_0.5-2     
 [19] papaja_0.1.0.9842         knitr_1.23.3             
 [21] shinythemes_1.1.1         zeallot_0.1.0            
 [23] bayesplot_1.6.0           jsonlite_1.6             
 [25] broom_0.5.2               shiny_1.1.0              
 [27] compiler_3.5.1            httr_1.4.0               
 [29] backports_1.1.4           assertthat_0.2.1         
 [31] Matrix_1.2-14             lazyeval_0.2.2           
 [33] cli_1.1.0                 later_0.7.5              
 [35] htmltools_0.3.6           prettyunits_1.0.2        
 [37] tools_3.5.1               igraph_1.2.2             
 [39] coda_0.19-2               gtable_0.2.0             
 [41] glue_1.3.1                reshape2_1.4.3           
 [43] Rcpp_1.0.1                cellranger_1.1.0         
 [45] vctrs_0.2.0               nlme_3.1-137             
 [47] crosstalk_1.0.0           xfun_0.8                 
 [49] ps_1.2.0                  rvest_0.3.2              
 [51] mime_0.7                  miniUI_0.1.1.1           
 [53] gtools_3.8.1              zoo_1.8-4                
 [55] scales_1.0.0              colourpicker_1.0         
 [57] hms_0.5.0                 promises_1.0.1           
 [59] Brobdingnag_1.2-6         parallel_3.5.1           
 [61] inline_0.3.15             shinystan_2.5.0          
 [63] yaml_2.2.0                gridExtra_2.3            
 [65] loo_2.0.0                 StanHeaders_2.18.0       
 [67] stringi_1.4.3             dygraphs_1.1.1.6         
 [69] pkgbuild_1.0.2            rlang_0.4.0              
 [71] pkgconfig_2.0.2           matrixStats_0.54.0       
 [73] HDInterval_0.2.0          evaluate_0.14            
 [75] lattice_0.20-35           rstantools_1.5.1         
 [77] htmlwidgets_1.3           tidyselect_0.2.5         
 [79] processx_3.2.0            here_0.1                 
 [81] plyr_1.8.4                magrittr_1.5             
 [83] R6_2.4.0                  generics_0.0.2           
 [85] pillar_1.4.2              haven_1.1.2              
 [87] withr_2.1.2               xts_0.11-1               
 [89] abind_1.4-5               modelr_0.1.3             
 [91] crayon_1.3.4              arrayhelpers_1.0-20160527
 [93] utf8_1.1.4                rmarkdown_1.14.1         
 [95] grid_3.5.1                readxl_1.2.0             
 [97] callr_3.0.0               threejs_0.3.1            
 [99] digest_0.6.20             xtable_1.8-3             
[101] httpuv_1.4.5              stats4_3.5.1             
[103] munsell_0.5.0             shinyjs_1.0 
mjskay commented 5 years ago

Thanks for the report!

It looks like you're using the dev version of tidyr. median_qi uses tidyr::unnest internally and it seems there are some API changes for unnest in the dev version of tidyr. It looks like it's still giving you the correct output, just with a deprecation warning.

I'll make sure to update tidybayes usage of unnest before the dev version of tidyr hits CRAN.

jamesrrae commented 5 years ago

That did the trick! Just wanted to make sure I was understanding the source of the warning.

mjskay commented 5 years ago

Great, glad to hear it!

I'm going to leave this open so I remember to revisit it to make sure I address the warnings before the dev version of tidyr hits CRAN.

mjskay commented 5 years ago

This is now fixed on 460334d363118bc41097f3044788c20d22d21ffd

I will release the fixed version onto CRAN shortly after the new tidyr hits CRAN, which I think is supposed to be soon