mjskay / tidybayes

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

spread_draws calls dpylr::combine, which is now depreciated #268

Closed hhau closed 4 years ago

hhau commented 4 years ago

I cannot for the life of me find whereabouts in tidybayes this happens though.

library(tidybayes)
library(brms)
#> Loading required package: Rcpp
#> Loading 'brms' package (version 2.12.0). Useful instructions
#> can be found by typing help('brms'). A more detailed introduction
#> to the package is available through vignette('brms_overview').
#> 
#> Attaching package: 'brms'
#> The following objects are masked from 'package:tidybayes':
#> 
#>     dstudent_t, pstudent_t, qstudent_t, rstudent_t
#> The following object is masked from 'package:stats':
#> 
#>     ar
library(tibble)

set.seed(5)
n = 10
n_condition = 5
ABC =
  tibble(
    condition = rep(c("A","B","C","D","E"), n),
    response = rnorm(n * 5, c(0,1,2,1,-1), 0.5)
  )

m = brm(
  response ~ (1|condition),
  data = ABC,
  prior = c(
    prior(normal(0, 1), class = Intercept),
    prior(student_t(3, 0, 1), class = sd),
    prior(student_t(3, 0, 1), class = sigma)
  ),
  control = list(adapt_delta = .99),
  cores = 4
)
#> Compiling the C++ model
#> Start sampling

m %>%
  spread_draws(r_condition[condition,term]) %>%
  head(10)
#> Warning: `combine()` is deprecated as of dplyr 1.0.0.
#> Please use `vctrs::vec_c()` instead.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_warnings()` to see where this warning was generated.
#> # A tibble: 10 x 6
#> # Groups:   condition, term [1]
#>    condition term      r_condition .chain .iteration .draw
#>    <chr>     <chr>           <dbl>  <int>      <int> <int>
#>  1 A         Intercept     -1.00        1          1     1
#>  2 A         Intercept     -0.454       1          2     2
#>  3 A         Intercept     -0.530       1          3     3
#>  4 A         Intercept     -0.0670      1          4     4
#>  5 A         Intercept     -0.0380      1          5     5
#>  6 A         Intercept     -0.236       1          6     6
#>  7 A         Intercept      0.103       1          7     7
#>  8 A         Intercept     -0.122       1          8     8
#>  9 A         Intercept     -0.479       1          9     9
#> 10 A         Intercept     -0.263       1         10    10

Created on 2020-08-11 by the reprex package (v0.3.0)

and the session info

R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

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

other attached packages:
[1] tibble_3.0.1    brms_2.12.0     Rcpp_1.0.4      tidybayes_2.1.1

loaded via a namespace (and not attached):
 [1] Brobdingnag_1.2-6    tidyr_1.0.2          gtools_3.8.2        
 [4] StanHeaders_2.19.0   threejs_0.3.3        assertthat_0.2.1    
 [7] shiny_1.4.0.2        distributional_0.1.0 stats4_3.6.3        
[10] ggdist_2.2.0         renv_0.9.3           backports_1.1.5     
[13] pillar_1.4.3         lattice_0.20-41      glue_1.3.2          
[16] arrayhelpers_1.1-0   digest_0.6.25        promises_1.1.0      
[19] colorspace_1.4-1     htmltools_0.4.0      httpuv_1.5.2        
[22] Matrix_1.2-18        plyr_1.8.6           dygraphs_1.1.1.6    
[25] pkgconfig_2.0.3      rstan_2.19.3         svUnit_0.7-12       
[28] purrr_0.3.3          xtable_1.8-4         mvtnorm_1.1-0       
[31] scales_1.1.0         processx_3.4.2       later_1.0.0         
[34] bayesplot_1.7.2      generics_0.0.2       farver_2.0.3        
[37] ggplot2_3.3.0        ellipsis_0.3.0       DT_0.13             
[40] shinyjs_1.1          cli_2.0.2            magrittr_1.5        
[43] crayon_1.3.4         mime_0.9             ps_1.3.2            
[46] fansi_0.4.1          nlme_3.1-145         forcats_0.5.0       
[49] xts_0.12-0           pkgbuild_1.0.6       colourpicker_1.0    
[52] prettyunits_1.1.1    rsconnect_0.8.16     tools_3.6.3         
[55] loo_2.2.0            lifecycle_0.2.0      matrixStats_0.56.0  
[58] stringr_1.4.0        munsell_0.5.0        callr_3.4.3         
[61] compiler_3.6.3       rlang_0.4.7          grid_3.6.3          
[64] ggridges_0.5.2       htmlwidgets_1.5.1    crosstalk_1.1.0.1   
[67] igraph_1.2.5         miniUI_0.1.1.1       base64enc_0.1-3     
[70] codetools_0.2-16     gtable_0.3.0         inline_0.3.15       
[73] abind_1.4-5          markdown_1.1         reshape2_1.4.3      
[76] R6_2.4.1             gridExtra_2.3        rstantools_2.0.0    
[79] zoo_1.8-8            bridgesampling_1.0-0 dplyr_1.0.1         
[82] utf8_1.1.4           fastmap_1.0.1        shinystan_2.5.0     
[85] shinythemes_1.1.2    stringi_1.4.6        parallel_3.6.3      
[88] vctrs_0.3.2          tidyselect_1.1.0     coda_0.19-3
mjskay commented 4 years ago

I believe that error was thrown inside either tibble or tidyr in an older version... try updating all your packages and see if the error goes away?

hhau commented 4 years ago

tidyr was the culprit, updating from 1.0.2 to 1.1.1 made the error disappear. Thanks! (I didn't want to update all my packages because I'm using renv to manage rstan / StanHeaders versions)