Fixing cropped Kable image in R - r

I have the following table using kableExtra in R
library(tidyverse)
library(kableExtra)
sr <- c('Positive (+)','Positive (+)','Negative (-)','Positive (+)')
lr <- c('Positive (+)','Neutral','Negative (-)','Positive (+)')
d <- c('GDP Response to Positive','','CPI Response to Positive','')
s <- c('AS Shock','AD Shock','AS Shock','AD Shock')
data.frame(d,s,sr,lr) %>%
kable(col.names = c('','','Short Run Effect','Long Run Effect'),'html') %>%
kable_styling() %>%
row_spec(0, col = 'white', background = '#7c3042') %>%
footnote(general="<b>These signs represent prior expectations for the short and long run dynamics
of variable responses to respective shocks, based on a conventional AS-AD framework<b>", escape = FALSE) %>%
column_spec(1:4,bold = T) %>%
save_kable(file = "table.png", density = 700)
For some odd reason, the table is slightly cropped off at the top when I save it. Any way to overcome this?
EDIT
Here is my session info
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_Namibia.1252 LC_CTYPE=English_Namibia.1252 LC_MONETARY=English_Namibia.1252
[4] LC_NUMERIC=C LC_TIME=English_Namibia.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] magick_2.6.0 hrbrthemes_0.8.0 lubridate_1.7.9.2 readxl_1.3.1 tbl2xts_1.0.4 feasts_0.1.6
[7] fabletools_0.3.0 tsbox_0.2.1 tsibble_0.9.3 Rcpp_1.0.6 kableExtra_1.3.1 forcats_0.5.0
[13] stringr_1.4.0 dplyr_1.0.3 purrr_0.3.4 readr_1.4.0 tidyr_1.1.2 tibble_3.0.5
[19] ggplot2_3.3.3 tidyverse_1.3.0
loaded via a namespace (and not attached):
[1] nlme_3.1-151 fs_1.5.0 xts_0.12.1 webshot_0.5.2
[5] httr_1.4.2 tools_4.0.3 backports_1.2.1 R6_2.5.0
[9] DBI_1.1.1 colorspace_2.0-0 withr_2.4.0 tidyselect_1.1.0
[13] processx_3.4.5 extrafontdb_1.0 curl_4.3 compiler_4.0.3
[17] cli_2.2.0 rvest_0.3.6 pacman_0.5.1 xml2_1.3.2
[21] sandwich_3.0-0 tseries_0.10-48 scales_1.1.1 lmtest_0.9-37
[25] quadprog_1.5-8 callr_3.5.1 systemfonts_0.3.2 digest_0.6.27
[29] foreign_0.8-81 rmarkdown_2.6 rio_0.5.16 pkgconfig_2.0.3
[33] htmltools_0.5.0 extrafont_0.17 dbplyr_2.0.0 highr_0.8
[37] rlang_0.4.9 TTR_0.24.2 rstudioapi_0.13 quantmod_0.4.18
[41] farver_2.0.3 generics_0.1.0 zoo_1.8-8 jsonlite_1.7.2
[45] distributional_0.2.1 zip_2.1.1 car_3.0-10 magrittr_2.0.1
[49] munsell_0.5.0 fansi_0.4.2 gdtools_0.2.3 abind_1.4-5
[53] lifecycle_0.2.0 stringi_1.5.3 carData_3.0-4 PerformanceAnalytics_2.0.4
[57] MASS_7.3-53 plyr_1.8.6 grid_4.0.3 parallel_4.0.3
[61] strucchange_1.5-2 crayon_1.3.4 lattice_0.20-41 haven_2.3.1
[65] hms_1.0.0 knitr_1.30 anytime_0.3.9 ps_1.5.0
[69] pillar_1.4.7 ggpubr_0.4.0 ggsignif_0.6.0 reshape2_1.4.4
[73] codetools_0.2-18 reprex_0.3.0 urca_1.3-0 glue_1.4.2
[77] evaluate_0.14 vars_1.5-3 data.table_1.13.6 modelr_0.1.8
[81] vctrs_0.3.6 foreach_1.5.1 Rttf2pt1_1.3.8 cellranger_1.1.0
[85] gtable_0.3.0 PortfolioAnalytics_1.1.0 assertthat_0.2.1 xfun_0.20
[89] openxlsx_4.2.3 broom_0.7.3 rstatix_0.6.0 viridisLite_0.3.0
[93] iterators_1.0.13 ellipsis_0.3.1

Related

Update atributte table columns contents (character type) from other joined csv table (r software)

I've tried merge and update columns values with this code.
For now the joined fields are correct. (#1)
Now I want update the fields of column.x with values in column.y.
I'm using the second part (#2) but without success.
#1 - code to merge table 'parcelas_sql' with 'tbd_con_sig' by 'codigo'
join_sig_csv <- merge(parcelas_sql, tbd_cons_sig, by.x = "codigo", by.y = "codigo", duplicateGeoms=TRUE)
#2 - update field 'n.cont.x' with 'n.cont.y' values
join_sig_csv[join_sig_csv$n.cont.x == n.cont.x] <- n.cont.y
error_message:
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'i' in selecting a method for function '[<-': object 'n.cont.x' not found
-------------------------------------- sessionInfo() -----------------
version 4.1.2 (2021-11-01)
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=Portuguese_Portugal.1252 LC_CTYPE=Portuguese_Portugal.1252 LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C
[5] LC_TIME=Portuguese_Portugal.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RODBC_1.3-19 maptools_1.1-4 sf_1.0-7 terra_1.5-21 spData_2.0.1 rgdal_1.5-32 rgeos_0.5-9 sp_1.4-6 rvest_1.0.2 showtext_0.9-5
[11] showtextdb_3.0 sysfonts_0.8.8 classInt_0.4-3 tmap_3.3-3 lubridate_1.8.0 fs_1.5.2 forcats_0.5.1 stringr_1.4.0 dplyr_1.0.7 purrr_0.3.4
[21] readr_2.1.1 tidyr_1.1.4 tibble_3.1.6 ggplot2_3.3.5 tidyverse_1.3.1
loaded via a namespace (and not attached):
[1] RColorBrewer_1.1-2 httr_1.4.2 tools_4.1.2 backports_1.4.1 utf8_1.2.2 R6_2.5.1
[7] KernSmooth_2.23-20 DBI_1.1.2 colorspace_2.0-2 raster_3.5-15 withr_2.4.3 tidyselect_1.1.1
[13] leaflet_2.1.1 compiler_4.1.2 leafem_0.2.0 cli_3.1.0 xml2_1.3.3 scales_1.1.1
[19] proxy_0.4-26 digest_0.6.29 foreign_0.8-81 base64enc_0.1-3 dichromat_2.0-0.1 pkgconfig_2.0.3
[25] htmltools_0.5.2 dbplyr_2.1.1 fastmap_1.1.0 htmlwidgets_1.5.4 rlang_0.4.12 readxl_1.3.1
[31] rstudioapi_0.13 generics_0.1.1 jsonlite_1.7.2 crosstalk_1.2.0 magrittr_2.0.1 Rcpp_1.0.7
[37] munsell_0.5.0 fansi_0.5.0 abind_1.4-5 lifecycle_1.0.1 stringi_1.7.6 leafsync_0.1.0
[43] tmaptools_3.1-1 grid_4.1.2 parallel_4.1.2 crayon_1.4.2 lattice_0.20-45 stars_0.5-5
[49] haven_2.4.3 hms_1.1.1 pillar_1.6.4 codetools_0.2-18 reprex_2.0.1 XML_3.99-0.8
[55] glue_1.6.0 leaflet.providers_1.9.0 modelr_0.1.8 png_0.1-7 vctrs_0.3.8 tzdb_0.2.0
[61] cellranger_1.1.0 gtable_0.3.0 assertthat_0.2.1 lwgeom_0.2-8 broom_0.7.11 e1071_1.7-9
[67] class_7.3-19 viridisLite_0.4.0 units_0.8-0 ellipsis_0.3.2

ShinyApp accents and special characters problems

I would like to know how I can solve the problem of accents and special characters, I don't know why special characters (´,ñ, etc) appear wrong, with the code I don't have any problem but when running the shiny app all the labels where this type of characters are appear as an attachment in the image below. I have read about saving with utf-8 encoding but the problem is still not fixed, below I share information about my session.
wrong labels: Número, Gráfico, Comunicación
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=Spanish_Spain.1252 LC_CTYPE=Spanish_Spain.1252
[3] LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Spain.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
other attached packages:
[1] stringi_1.6.1 plotly_4.10.0 ggplot2_3.3.5
[4] dplyr_1.0.7 shinyFiles_0.9.1 visNetwork_2.1.0
[7] openxlsx_4.2.4 shinyalert_2.0.0 lubridate_1.7.10
[10] data.table_1.14.2 DT_0.20 shinyjs_2.0.0
[13] shiny_1.7.1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.6 lattice_0.20-38 tidyr_1.1.4
[4] assertthat_0.2.1 digest_0.6.27 utf8_1.2.1
[7] mime_0.10 R6_2.5.1 evaluate_0.14
[10] httr_1.4.2 pillar_1.6.4 rlang_0.4.11
[13] uuid_0.1-4 lazyeval_0.2.2 fontawesome_0.2.2
[16] rstudioapi_0.13 jquerylib_0.1.4 rmarkdown_2.11
[19] foreign_0.8-75 htmlwidgets_1.5.4 munsell_0.5.0
[22] compiler_3.6.3 httpuv_1.6.1 xfun_0.30
[25] pkgconfig_2.0.3 htmltools_0.5.2 tidyselect_1.1.1
[28] tibble_3.1.1 fansi_0.4.2 viridisLite_0.4.0
[31] crayon_1.4.2 withr_2.4.2 later_1.2.0
[34] grid_3.6.3 jsonlite_1.7.2 xtable_1.8-4
[37] gtable_0.3.0 lifecycle_1.0.1 DBI_1.1.2
[40] magrittr_2.0.1 scales_1.1.1 zip_2.2.0
[43] cli_3.1.0 cachem_1.0.4 fs_1.5.0
[46] promises_1.2.0.1 sp_1.4-6 bslib_0.3.1
[49] ellipsis_0.3.2 generics_0.1.1 vctrs_0.3.8
[52] tools_3.6.3 glue_1.4.2 purrr_0.3.4
[55] crosstalk_1.1.1 rsconnect_0.8.25 fastmap_1.1.0
[58] yaml_2.2.1 colorspace_2.0-1 maptools_1.1-2
[61] knitr_1.36 sass_0.4.0

Error in h(simpleError(msg, call)) : error in evaluating the argument 'object' in selecting a method for function 'getBeta'

I am trying to get Beta files using the minfi packacge. I succeeded with almost all my datasets. Therefor I ran the following code:
# find idat files
test_data <- list.files(path = "./Idat Files",
pattern = "_Grn.idat",
full.names = TRUE)
# load data
test_data <- minfi::read.metharray(basenames = test_data) %>%
preprocessNoob %>%
getBeta
Problem #1: Unfortunately I got the following error:
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'object' in selecting a method for function 'getBeta': cannot load annotation package IlluminaHumanMethylationEPICanno.ilm10b4.hg19
Problem #2: Calling Beta values from another data set, using the same code as above, gave me another error:
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'object' in selecting a method for function 'getBeta': [read.metharray] Trying to parse IDAT files with different array size but seemingly all of the same type.
You can force this by 'force=TRUE', see the man page ?read.metharray
Question: Does someone know what is going wrong?
sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=Dutch_Netherlands.1252 LC_CTYPE=Dutch_Netherlands.1252 LC_MONETARY=Dutch_Netherlands.1252
[4] LC_NUMERIC=C LC_TIME=Dutch_Netherlands.1252
attached base packages:
[1] parallel stats4 stats graphics grDevices utils datasets methods base
other attached packages:
[1] IlluminaHumanMethylationEPICmanifest_0.3.0 forcats_0.5.1
[3] stringr_1.4.0 dplyr_1.0.8
[5] purrr_0.3.4 readr_2.1.2
[7] tidyr_1.2.0 tibble_3.1.6
[9] ggplot2_3.3.5 tidyverse_1.3.1
[11] minfiData_0.40.0 IlluminaHumanMethylation450kanno.ilmn12.hg19_0.6.0
[13] IlluminaHumanMethylation450kmanifest_0.4.0 RFpurify_0.1.2
[15] minfi_1.40.0 bumphunter_1.36.0
[17] locfit_1.5-9.5 iterators_1.0.14
[19] foreach_1.5.2 Biostrings_2.62.0
[21] XVector_0.34.0 SummarizedExperiment_1.24.0
[23] Biobase_2.54.0 MatrixGenerics_1.6.0
[25] matrixStats_0.61.0 GenomicRanges_1.46.1
[27] GenomeInfoDb_1.30.1 IRanges_2.28.0
[29] S4Vectors_0.32.4 BiocGenerics_0.40.0
loaded via a namespace (and not attached):
[1] readxl_1.4.0 backports_1.4.1 BiocFileCache_2.2.1 plyr_1.8.7
[5] splines_4.1.3 BiocParallel_1.28.3 digest_0.6.29 htmltools_0.5.2
[9] fansi_1.0.3 magrittr_2.0.3 memoise_2.0.1 tzdb_0.3.0
[13] limma_3.50.3 annotate_1.72.0 modelr_0.1.8 askpass_1.1
[17] siggenes_1.68.0 prettyunits_1.1.1 colorspace_2.0-3 rvest_1.0.2
[21] blob_1.2.3 rappdirs_0.3.3 haven_2.4.3 xfun_0.30
[25] jsonlite_1.8.0 crayon_1.5.1 RCurl_1.98-1.6 genefilter_1.76.0
[29] GEOquery_2.62.2 survival_3.2-13 glue_1.6.2 gtable_0.3.0
[33] zlibbioc_1.40.0 DelayedArray_0.20.0 Rhdf5lib_1.16.0 HDF5Array_1.22.1
[37] scales_1.2.0 DBI_1.1.2 rngtools_1.5.2 Rcpp_1.0.8.3
[41] xtable_1.8-4 progress_1.2.2 bit_4.0.4 mclust_5.4.9
[45] preprocessCore_1.56.0 httr_1.4.2 RColorBrewer_1.1-3 ellipsis_0.3.2
[49] farver_2.1.0 pkgconfig_2.0.3 reshape_0.8.9 XML_3.99-0.9
[53] dbplyr_2.1.1 utf8_1.2.2 labeling_0.4.2 tidyselect_1.1.2
[57] rlang_1.0.2 AnnotationDbi_1.56.2 cellranger_1.1.0 munsell_0.5.0
[61] tools_4.1.3 cachem_1.0.6 cli_3.2.0 generics_0.1.2
[65] RSQLite_2.2.12 broom_0.8.0 evaluate_0.15 fastmap_1.1.0
[69] yaml_2.3.5 fs_1.5.2 knitr_1.38 bit64_4.0.5
[73] beanplot_1.3.1 scrime_1.3.5 randomForest_4.7-1 KEGGREST_1.34.0
[77] nlme_3.1-155 doRNG_1.8.2 sparseMatrixStats_1.6.0 nor1mix_1.3-0
[81] xml2_1.3.3 biomaRt_2.50.3 compiler_4.1.3 rstudioapi_0.13
[85] filelock_1.0.2 curl_4.3.2 png_0.1-7 reprex_2.0.1
[89] stringi_1.7.6 GenomicFeatures_1.46.5 lattice_0.20-45 Matrix_1.4-0
[93] multtest_2.50.0 vctrs_0.4.0 pillar_1.7.0 lifecycle_1.0.1
[97] rhdf5filters_1.6.0 data.table_1.14.2 bitops_1.0-7 rtracklayer_1.54.0
[101] R6_2.5.1 BiocIO_1.4.0 codetools_0.2-18 MASS_7.3-55
[105] assertthat_0.2.1 rhdf5_2.38.1 openssl_2.0.0 rjson_0.2.21
[109] withr_2.5.0 GenomicAlignments_1.30.0 Rsamtools_2.10.0 GenomeInfoDbData_1.2.7
[113] hms_1.1.1 quadprog_1.5-8 grid_4.1.3 base64_2.0
[117] rmarkdown_2.13 DelayedMatrixStats_1.16.0 illuminaio_0.36.0 lubridate_1.8.0

XDG_RUNTIME_DIR when exporting kable to image (Rstudio + Ubuntu 20.04)

I'm trying to export table made with kableExtra in R. It looks ok in the R Studio environment but if I try to export it it gives me this error:
> kable(csv) %>%
+ kable_styling("striped", full_width = F, htmltable_class = 'Liberation Sans') %>%
+ kable_minimal() %>%
+ save_kable(file = paste0(outdir, name, '.png'), bs_theme = "flatly",
+ zoom = 1.5)
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-cesarkero'
error: XDG_RUNTIME_DIR not set in the environment.
TypeError: Attempting to change the setter of an unconfigurable property.
TypeError: Attempting to change the setter of an unconfigurable property.
Error in magick_image_trim(image, fuzz) :
rsession: geometry does not contain image `/home/cesarkero/HDD/D4/GoogleDrive/Proyectos/Master_UNED/01_Materias/06_EE/07_Trabajo/03_Resultados/04_CONSOLIDADOS/07a.png' # warning/attribute.c/GetImageBoundingBox/247
The file is exported but totally empty.
Here is the file used as csv object: https://drive.google.com/file/d/1fmplGNKB7MSKvXpNI_YrThE1F2EKszTf/view?usp=sharing
Update 19/04/2022
If I try this I get a similar error:
> webshot::install_phantomjs()
Error: invalid version specification ‘QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-cesarkero'’
I had already installed phantomjs in linux terminal with:
sudo apt-get install -y phantomjs
Here is my sessionInfo():
> sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.4 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3
locale:
[1] LC_CTYPE=es_ES.UTF-8 LC_NUMERIC=C
[3] LC_TIME=es_ES.UTF-8 LC_COLLATE=es_ES.UTF-8
[5] LC_MONETARY=es_ES.UTF-8 LC_MESSAGES=es_ES.UTF-8
[7] LC_PAPER=es_ES.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=es_ES.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] landtools_0.1.0 lubridate_1.8.0 plyr_1.8.6
[4] data.table_1.14.2 raster_3.5-15 rgeos_0.5-9
[7] rgdal_1.5-28 sp_1.4-6 exifr_0.3.2
[10] nngeo_0.4.5 spatstat_2.3-3 spatstat.linnet_2.3-2
[13] spatstat.core_2.4-0 rpart_4.1.16 nlme_3.1-157
[16] spatstat.random_2.1-0 spatstat.geom_2.3-2 spatstat.data_2.1-2
[19] purrr_0.3.4 readODS_1.7.0 stringr_1.4.0
[22] mapview_2.10.0 dplyr_1.0.8 readr_2.1.2
[25] sf_1.0-7 magrittr_2.0.3 magick_2.7.3
[28] kableExtra_1.3.4
loaded via a namespace (and not attached):
[1] spatstat.sparse_2.1-0 satellite_1.0.4 webshot_0.5.2
[4] httr_1.4.2 tools_4.1.3 utf8_1.2.2
[7] R6_2.5.1 KernSmooth_2.23-20 DBI_1.1.2
[10] mgcv_1.8-40 colorspace_2.0-3 processx_3.5.2
[13] tidyselect_1.1.2 leaflet_2.1.0 compiler_4.1.3
[16] leafem_0.1.6 cli_3.2.0 rvest_1.0.2
[19] xml2_1.3.3 scales_1.1.1 classInt_0.4-3
[22] callr_3.7.0 proxy_0.4-26 rappdirs_0.3.3
[25] goftest_1.2-3 systemfonts_1.0.4 digest_0.6.29
[28] foreign_0.8-82 spatstat.utils_2.3-0 rmarkdown_2.13
[31] svglite_2.1.0 base64enc_0.1-3 pkgconfig_2.0.3
[34] htmltools_0.5.2 fastmap_1.1.0 htmlwidgets_1.5.4
[37] rlang_1.0.2 rstudioapi_0.13 generics_0.1.2
[40] crosstalk_1.2.0 Matrix_1.4-1 Rcpp_1.0.8.2
[43] munsell_0.5.0 fansi_1.0.3 abind_1.4-5
[46] lifecycle_1.0.1 terra_1.5-21 stringi_1.7.6
[49] maptools_1.1-3 grid_4.1.3 crayon_1.5.1
[52] deldir_1.0-6 lattice_0.20-45 splines_4.1.3
[55] tensor_1.5 hms_1.1.1 ps_1.6.0
[58] knitr_1.37 pillar_1.7.0 codetools_0.2-18
[61] stats4_4.1.3 glue_1.6.2 evaluate_0.15
[64] png_0.1-7 vctrs_0.4.0 tzdb_0.2.0
[67] polyclip_1.10-0 assertthat_0.2.1 xfun_0.30
[70] e1071_1.7-9 class_7.3-20 viridisLite_0.4.0
[73] tibble_3.1.6 units_0.8-0 ellipsis_0.3.2
First you need to install the phantomjs from the webshot package using the following code:
webshot::install_phantomjs()
After that, you can run the following code which will output your table as table.png:
library(knitr)
library(kableExtra)
library(magrittr)
kable(csv) %>%
kable_styling("striped", full_width = F, htmltable_class = 'Liberation Sans') %>%
kable_minimal() %>%
save_kable(file = "table.png", bs_theme = "flatly", zoom = 1.5)
The output looks like this:
Please note that your table is really big.
Here is my sessionInfo:
> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS 12.3.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
locale:
[1] nl_NL.UTF-8/nl_NL.UTF-8/nl_NL.UTF-8/C/nl_NL.UTF-8/nl_NL.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] readxl_1.3.1 ggforce_0.3.3 dummies_1.5.6 plyr_1.8.6 magrittr_2.0.3 knitr_1.37
[7] kableExtra_1.3.4 terra_1.5-21 reshape_0.8.8 epitools_0.5-10.1 forcats_0.5.1 stringr_1.4.0
[13] readr_2.1.2 tidyverse_1.3.1 DALEXtra_2.1.1 DALEX_2.4.0 mlbench_2.1-3 yardstick_0.0.9
[19] workflowsets_0.1.0 workflows_0.2.4 tune_0.1.6 tidyr_1.2.0 tibble_3.1.6 rsample_0.1.1
[25] recipes_0.2.0 purrr_0.3.4 parsnip_0.2.0 modeldata_0.1.1 infer_1.0.0 ggplot2_3.3.5
[31] dplyr_1.0.8 dials_0.1.0 scales_1.1.1 broom_0.7.12 tidymodels_0.1.4 mapview_2.10.0
loaded via a namespace (and not attached):
[1] utf8_1.2.2 reticulate_1.24 tidyselect_1.1.2 htmlwidgets_1.5.4 grid_4.1.0 pROC_1.18.0
[7] munsell_0.5.0 codetools_0.2-18 units_0.8-0 future_1.24.0 withr_2.5.0 colorspace_2.0-3
[13] highr_0.9 uuid_1.0-4 rstudioapi_0.13 stats4_4.1.0 Rttf2pt1_1.3.8 listenv_0.8.0
[19] labeling_0.4.2 polyclip_1.10-0 plotROC_2.2.1 bit64_4.0.5 DiceDesign_1.9 farver_2.1.0
[25] rprojroot_2.0.2 parallelly_1.30.0 vctrs_0.4.0 generics_0.1.2 ipred_0.9-12 xfun_0.30
[31] R6_2.5.1 doParallel_1.0.17 ggiraph_0.8.2 flexmix_2.3-17 lhs_1.1.4 assertthat_0.2.1
[37] vroom_1.5.7 nnet_7.3-17 gtable_0.3.0 globals_0.14.0 processx_3.5.2 timeDate_3043.102
[43] rlang_1.0.2 systemfonts_1.0.4 modMax_1.1 splines_4.1.0 rgdal_1.5-28 extrafontdb_1.0
[49] lazyeval_0.2.2 ModelMetrics_1.2.2.2 yaml_2.3.5 reshape2_1.4.4 modelr_0.1.8 crosstalk_1.2.0
[55] backports_1.4.1 caret_6.0-90 extrafont_0.17 tools_4.1.0 lava_1.6.10 ellipsis_0.3.2
[61] raster_3.5-15 jquerylib_0.1.4 proxy_0.4-26 Rcpp_1.0.8.3 base64enc_0.1-3 progress_1.2.2
[67] classInt_0.4-3 ps_1.6.0 prettyunits_1.1.1 rpart_4.1.16 haven_2.4.3 fs_1.5.2
[73] here_1.0.1 leafem_0.1.6 furrr_0.2.3 magick_2.7.3 data.table_1.14.2 SparseM_1.81
[79] reprex_2.0.1 GPfit_1.0-8 hms_1.1.1 evaluate_0.15 leaflet_2.0.3.9000 compiler_4.1.0
[85] ingredients_2.2.0 KernSmooth_2.23-20 crayon_1.5.1 htmltools_0.5.2 tzdb_0.2.0 lubridate_1.8.0
[91] DBI_1.1.2 tweenr_1.0.2 dbplyr_2.1.1 MASS_7.3-55 sf_1.0-7 Matrix_1.4-0
[97] cli_3.2.0 parallel_4.1.0 gower_1.0.0 igraph_1.2.11 pkgconfig_2.0.3 sp_1.4-6
[103] plotly_4.10.0 xml2_1.3.3 foreach_1.5.2 svglite_2.1.0 bslib_0.3.1 hardhat_0.2.0
[109] webshot_0.5.2 prodlim_2019.11.13 rvest_1.0.2 callr_3.7.0 digest_0.6.29 rmarkdown_2.13
[115] cellranger_1.1.0 kernlab_0.9-29 gtools_3.9.2 satellite_1.0.4 modeltools_0.2-23 lifecycle_1.0.1
[121] nlme_3.1-155 jsonlite_1.8.0 viridisLite_0.4.0 fansi_1.0.3 pillar_1.7.0 lattice_0.20-45
[127] fastmap_1.1.0 httr_1.4.2 survival_3.3-1 glue_1.6.2 png_0.1-7 iterators_1.0.14
[133] bit_4.0.4 class_7.3-20 stringi_1.7.6 sass_0.4.1 e1071_1.7-9 future.apply_1.8.1

Error: All list elements must be lists themselves: Error in using spread_draws function in tidybayes

In playing around with the tidybayes package (I replicated the data from the code simulated in the vignette: http://mjskay.github.io/tidybayes/articles/tidybayes.html), I continue to stumble onto the error: Error: All list elements must be lists themselves when using the spread_draws function (or any other functions in the tidybayes, for that matter). Here is the simulated data from the vignette:
library(tidyverse)
library(tidybayes)
library(brms)
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)
)
Here is the code for fitting the model:
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)
)
But, even in trying to use the get_variables function, I get the same error as mentioned above. Has anyone else had a similar problem or been able to solve this one?
Here is the session info.
> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] tidybayes_3.0.1 see_0.6.7 bayestestR_0.11.0 semTools_0.5-5
[5] lavaan_0.6-9 HDInterval_0.2.2 brms_2.15.0 Rcpp_1.0.6
[9] ggsignif_0.6.2 reshape2_1.4.4 ggsci_2.9 psych_2.0.12
[13] jtools_2.1.3 magrittr_2.0.1 extrafont_0.17 ggthemes_4.2.4
[17] forcats_0.5.1 stringr_1.4.0 dplyr_1.0.4 purrr_0.3.4
[21] tidyr_1.1.2 tibble_3.0.6 tidyverse_1.3.0 gridExtra_2.3
[25] ggpubr_0.4.0 ggplot2_3.3.5 readr_1.4.0
loaded via a namespace (and not attached):
[1] utf8_1.1.4 tidyselect_1.1.0 lme4_1.1-26
[4] htmlwidgets_1.5.3 grid_4.0.3 munsell_0.5.0
[7] codetools_0.2-18 statmod_1.4.35 DT_0.18
[10] miniUI_0.1.1.1 withr_2.4.1 Brobdingnag_1.2-6
[13] colorspace_2.0-0 knitr_1.31 rstudioapi_0.13
[16] stats4_4.0.3 Rttf2pt1_1.3.9 bayesplot_1.8.1
[19] labeling_0.4.2 emmeans_1.5.4 rstan_2.21.2
[22] mnormt_2.0.2 farver_2.0.3 datawizard_0.2.0.1
[25] bridgesampling_1.1-2 coda_0.19-4 vctrs_0.3.6
[28] generics_0.1.0 TH.data_1.0-10 xfun_0.25
[31] R6_2.5.0 markdown_1.1 gamm4_0.2-6
[34] projpred_2.0.2 assertthat_0.2.1 promises_1.2.0.1
[37] scales_1.1.1 multcomp_1.4-16 debugme_1.1.0
[40] gtable_0.3.0 processx_3.5.2 sandwich_3.0-0
[43] rlang_0.4.10 splines_4.0.3 rstatix_0.7.0
[46] extrafontdb_1.0 checkmate_2.0.0 broom_0.7.7
[49] inline_0.3.17 yaml_2.2.1 abind_1.4-5
[52] modelr_0.1.8 threejs_0.3.3 crosstalk_1.1.1
[55] backports_1.2.1 httpuv_1.5.5 rsconnect_0.8.18
[58] tensorA_0.36.2 tools_4.0.3 ellipsis_0.3.1
[61] posterior_1.0.1 ggridges_0.5.3 plyr_1.8.6
[64] base64enc_0.1-3 ps_1.5.0 prettyunits_1.1.1
[67] zoo_1.8-8 haven_2.3.1 fs_1.5.0
[70] data.table_1.14.0 ggdist_3.0.0 openxlsx_4.2.3
[73] colourpicker_1.1.0 reprex_1.0.0 tmvnsim_1.0-2
[76] mvtnorm_1.1-1 matrixStats_0.58.0 hms_1.0.0
[79] shinyjs_2.0.0 mime_0.10 evaluate_0.14
[82] arrayhelpers_1.1-0 xtable_1.8-4 shinystan_2.5.0
[85] rio_0.5.16 readxl_1.3.1 rstantools_2.1.1
[88] compiler_4.0.3 V8_3.4.2 crayon_1.4.1
[91] minqa_1.2.4 StanHeaders_2.21.0-7 htmltools_0.5.1.1
[94] mgcv_1.8-34 later_1.1.0.1 RcppParallel_5.1.4
[97] lubridate_1.7.10 DBI_1.1.1 dbplyr_2.1.0
[100] MASS_7.3-54 boot_1.3-27 Matrix_1.3-2
[103] car_3.0-10 cli_2.5.0 parallel_4.0.3
[106] insight_0.14.4 igraph_1.2.6 pkgconfig_2.0.3
[109] foreign_0.8-81 xml2_1.3.2 svUnit_1.0.6
[112] dygraphs_1.1.1.6 pbivnorm_0.6.0 estimability_1.3
[115] rvest_1.0.0 distributional_0.2.2 callr_3.7.0
[118] digest_0.6.27 rmarkdown_2.10 cellranger_1.1.0
[121] curl_4.3 shiny_1.6.0 gtools_3.8.2
[124] nloptr_1.2.2.2 lifecycle_1.0.0 nlme_3.1-152
[127] jsonlite_1.7.2 carData_3.0-4 fansi_0.4.2
[130] pillar_1.5.0 lattice_0.20-41 loo_2.4.1
[133] fastmap_1.1.0 httr_1.4.2 pkgbuild_1.2.0
[136] survival_3.2-11 glue_1.4.2 xts_0.12.1
[139] zip_2.1.1 shinythemes_1.2.0 pander_0.6.3
[142] stringi_1.5.3
If you need any other information or if I oversaw providing something, please let me know!
Many thanks for your help and all the best.
I just encountered the same problem. It seems to be a bug in the recent version 3.0.1. If you fall back on the previous version, your code should work.
devtools::install_version("tidybayes", version = "3.0.0", repos = "http://cran.us.r-project.org")
I've posted the issue on GitHub: https://github.com/mjskay/tidybayes/issues/289

Resources