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() fails on tidybayes "ABC" example #240

Closed apollostream closed 4 years ago

apollostream commented 4 years ago

m = sampling(ABC_stan, data = compose_data(ABC), control = list(adapt_delta=0.99)) m %<>% recover_types(ABC) m %>%

  • spread_draws(condition_mean[condition], response_sd) %>%
  • head(15) # just show the first few rows Error: Assigned data draws[, c(".chain", ".iteration", ".draw")] must be compatible with existing data. x Existing data has 20000 rows. x Element 1 of assigned data has 4000 rows. i Only vectors of size 1 are recycled. Run rlang::last_error() to see where the error occurred. rlang::last_error() <error/tibble_error_assign_incompatible_size> Assigned data draws[, c(".chain", ".iteration", ".draw")] must be compatible with existing data. x Existing data has 20000 rows. x Element 1 of assigned data has 4000 rows. i Only vectors of size 1 are recycled. Backtrace:
    1. tidybayes::spread_draws(., condition_mean[condition], response_sd)
    2. base::lapply(...)
    3. tidybayes:::FUN(X[[i]], ...)
    4. tidybayes:::spreaddraws(...)
    5. tidybayes:::spread_drawslong(...)
    6. tibble:::[<-.tbl_df(...)
    7. tibble:::tbl_subassign(x, i, j, value, i_arg, j_arg, substitute(value))
    8. tibble:::vectbl_recycle_rhs(...)
    9. base::tryCatch(...)
    10. base:::tryCatchList(expr, classes, parentenv, handlers)
    11. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
    12. value[3L] Run rlang::last_trace() to see the full context. sessionInfo() R version 3.6.2 (2019-12-12) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

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

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

other attached packages: [1] cowplot_1.0.0 tidybayes_2.0.2 forcats_0.5.0 stringr_1.4.0
[5] dplyr_0.8.5 purrr_0.3.3 readr_1.3.1 tidyr_1.0.2
[9] tibble_3.0.0 tidyverse_1.3.0 magrittr_1.5 rstan_2.19.3
[13] ggplot2_3.3.0 StanHeaders_2.21.0-1

loaded via a namespace (and not attached): [1] Rcpp_1.0.4 lubridate_1.7.4 lattice_0.20-40 prettyunits_1.1.1 ps_1.3.2
[6] digest_0.6.25 assertthat_0.2.1 plyr_1.8.6 R6_2.4.1 cellranger_1.1.0
[11] backports_1.1.5 reprex_0.3.0 stats4_3.6.2 coda_0.19-3 httr_1.4.1
[16] pillar_1.4.3 rlang_0.4.5 readxl_1.3.1 rstudioapi_0.11 callr_3.4.3
[21] labeling_0.3 loo_2.2.0 munsell_0.5.0 broom_0.5.5 compiler_3.6.2
[26] modelr_0.1.6 pkgconfig_2.0.3 pkgbuild_1.0.6 tidyselect_1.0.0 gridExtra_2.3
[31] codetools_0.2-16 arrayhelpers_1.1-0 matrixStats_0.56.0 fansi_0.4.1 crayon_1.3.4
[36] dbplyr_1.4.2 withr_2.1.2 grid_3.6.2 nlme_3.1-145 jsonlite_1.6.1
[41] gtable_0.3.0 lifecycle_0.2.0 DBI_1.1.0 scales_1.1.0 cli_2.0.2
[46] stringi_1.4.6 farver_2.0.3 fs_1.3.2 xml2_1.2.5 ellipsis_0.3.0
[51] generics_0.0.2 vctrs_0.2.4 tools_3.6.2 svUnit_0.7-12 glue_1.3.2
[56] hms_0.5.3 processx_3.4.2 parallel_3.6.2 inline_0.3.15 colorspace_1.4-1
[61] rvest_0.3.5 haven_2.2.0

mjskay commented 4 years ago

Ah my guess is this is related to the new version of tibble, I'll look into it this week and push a fix to cran

apollostream commented 4 years ago

Thank you! Much appreciate the quick response..

brockk commented 4 years ago

Hi Matt,

Hope you are well.

I am just looking at some errors in trialr, also arising from the new tibble on CRAN. A call in my package to gather_draws is failing with essentially the same error as that listed above by original poster. I see you are working on new CRAN release. Please let me know when that goes live.

Thanks, Kristian

mjskay commented 4 years ago

This is fixed on master now. Based on historical turnaround for small fixes I'd hope the new version will be on CRAN by the end of the weekend, but of course no guarantees.

@brockk if you follow github releases for tidybayes (Watch -> releases only) you can get a notification when there's a github release (which happens whenever a new version hits CRAN). I've found this helpful when tracking dependencies I am waiting for changes on :)

brockk commented 4 years ago

Thanks very much @mjskay. Everything working nicely now this end. I have subscribed to release alerts too. Cheers pal.

mjskay commented 4 years ago

Great, glad to hear that fixed it, cheers @brockk!