Unable to run flexdashboard example code - - r

I am trying to run a flexdashboard with a couple plotly graphs, but I receive the error:
Error in switch(options$dev, pdf = ".pdf", jpeg = ".jpeg", ".png") :
EXPR must be a length 1 vector Calls: <Anonymous> ... fun ->
withVisible -> knit_print -> html_screenshot
The example code I am running is a set of ggplotly example code.
Session info:
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] maps_3.2.0 bindrcpp_0.2 highcharter_0.5.0 quantmod_0.4-12 TTR_0.23-3
[6] xts_0.10-0 zoo_1.8-0 formattable_0.2.0.1 officer_0.2.1 flextable_0.4.2
[11] gridExtra_2.3 knitr_1.17 kableExtra_0.7.0 dplyr_0.7.4 lubridate_1.6.0
[16] rstudioapi_0.7 RODBC_1.3-15 plotly_4.7.1 ggplot2_2.2.1
loaded via a namespace (and not attached):
[1] httr_1.3.1 tidyr_0.7.2 jsonlite_1.5 viridisLite_0.2.0 R.utils_2.6.0
[6] shiny_1.0.5 assertthat_0.2.0 yaml_2.1.16 gdtools_0.1.6 backports_1.1.1
[11] lattice_0.20-35 glue_1.1.1 rlist_0.4.6.1 uuid_0.1-2 digest_0.6.12
[16] rvest_0.3.2 colorspace_1.3-2 htmltools_0.3.6 httpuv_1.3.5 R.oo_1.21.0
[21] plyr_1.8.4 psych_1.7.8 pkgconfig_2.0.1 broom_0.4.2 flexdashboard_0.5.1
[26] purrr_0.2.3 xtable_1.8-2 scales_0.5.0 tibble_1.3.4 lazyeval_0.2.0
[31] mnormt_1.5-5 magrittr_1.5 mime_0.5 evaluate_0.10.1 R.methodsS3_1.7.1
[36] nlme_3.1-131 xml2_1.1.1 foreign_0.8-69 tools_3.3.1 data.table_1.10.4
[41] hms_0.3 stringr_1.2.0 munsell_0.4.3 zip_1.0.0 rlang_0.1.2
[46] htmlwidgets_1.0 crosstalk_1.0.0 igraph_1.1.2 base64enc_0.1-3 labeling_0.3
[51] rmarkdown_1.6 gtable_0.2.0 curl_3.0 reshape2_1.4.2 R6_2.2.2
[56] bindr_0.1 rprojroot_1.2 readr_1.1.1 stringi_1.1.5 parallel_3.3.1
[61] Rcpp_0.12.12 tidyselect_0.2.0
A similar error resulted in the case of this question on github, but I am not using shiny nor do I set a working directory in the code. Any ideas?

Overview
From All apps with htmlwidgets failing to render on Mac after #150, Yihui identified this error with version 1.17 of the knitr package.
This is the same version you currently have installed (see 'other attached packages' section in sessionInfo()). To squash the error message, please run the following code in r to update the knitr package to version 1.19:
# install package from CRAN
install.packages( pkgs = 'knitr' )

Related

choroplethrZip returning "cannot add bindings" subtitle error - even with example code

choroplethrZip is returning a "cannot add bindings" error even when I use example code like the following:
library(choroplethrZip)
data(df_pop_zip)
zip_choropleth(df_pop_zip,
state_zoom = "new york",
title = "2012 New York State ZCTA Population Estimates",
legend = "Population")
Error in c$subtitle = subtitle :
cannot add bindings to a locked environment
sessionInfo()
R version 3.5.1 (2018-07-02)
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 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] choroplethrZip_1.5.0
loaded via a namespace (and not attached):
[1] httr_1.3.1 maps_3.3.0 splines_3.5.1 Formula_1.2-3 assertthat_0.2.0 sp_1.3-1 latticeExtra_0.6-28
[8] yaml_2.1.19 pillar_1.3.0 backports_1.1.2 lattice_0.20-35 glue_1.3.0 uuid_0.1-2 digest_0.6.15
[15] RColorBrewer_1.1-2 checkmate_1.8.5 colorspace_1.3-2 htmltools_0.3.6 Matrix_1.2-14 plyr_1.8.4 XML_3.98-1.12
[22] pkgconfig_2.0.1 WDI_2.5 purrr_0.2.5 scales_0.5.0 jpeg_0.1-8 tigris_0.7 ggmap_2.6.1
[29] htmlTable_1.12 tibble_1.4.2 ggplot2_3.0.0 nnet_7.3-12 lazyeval_0.2.1 proto_1.0.0 survival_2.42-6
[36] RJSONIO_1.3-0 magrittr_1.5 crayon_1.3.4 maptools_0.9-2 acs_2.1.3 foreign_0.8-71 class_7.3-14
[43] tools_3.5.1 data.table_1.11.4 geosphere_1.5-7 RgoogleMaps_1.4.2 stringr_1.3.1 munsell_0.5.0 cluster_2.0.7-1
[50] bindrcpp_0.2.2 compiler_3.5.1 e1071_1.6-8 rlang_0.2.1 classInt_0.2-3 units_0.6-0 grid_3.5.1
[57] rstudioapi_0.7 rjson_0.2.20 rappdirs_0.3.1 htmlwidgets_1.2 base64enc_0.1-3 gtable_0.2.0 DBI_1.0.0
[64] reshape2_1.4.3 R6_2.2.2 gridExtra_2.3 knitr_1.20 dplyr_0.7.6 rgdal_1.3-3 bindr_0.1.1
[71] choroplethr_3.6.2 Hmisc_4.1-1 stringi_1.1.7 Rcpp_0.12.18 mapproj_1.2.6 sf_0.6-3 rpart_4.1-13
[78] acepack_1.4.1 png_0.1-7 spData_0.2.9.0 tidyselect_0.2.4
The new ggplot version (3.0.0) necessitates an edit to the choroplethrZip package's zip_choropleth.R, as package author Ari Lamstein described for the choroplehtr package at https://arilamstein.com/blog/2018/06/27/choroplethr-v3-6-2-is-now-on-cran/:
Add a comma after the last function (render_helper) in zip_choropleth.R and then insert this code:
theme_clean = function()
{
ggplot2::theme_void()
},
theme_inset = function()
{
ggplot2::theme_void() %+replace%
ggplot2::theme(legend.position = "none")
}
You will need a local version of the package, which you can download from https://github.com/arilamstein/choroplethrZip. Edit zip_choropleth.R and then locally install the code with the devtools package a la:
devtools::install_local('C:/Users/RickPack/Downloads/choroplethrZip-master')

Error when connecting sparklyr to local

I'm trying to run sparklyr from my local environment to replicate a production environment. However, I can't even get started. I successfully installed the latest version of Spark using spark_install(), but when trying to run spark_connect() I get this vague and unhelpful error.
> library(sparklyr)
> spark_installed_versions()
spark hadoop dir
1 2.3.1 2.7 C:\\Users\\...\\AppData\\Local/spark/spark-2.3.1-bin-hadoop2.7
> spark_connect(master = "local")
Error in if (is.na(a)) return(-1L) : argument is of length zero
Here is what my session info looks like.
> sessionInfo()
R version 3.5.0 (2018-04-23)
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] sparklyr_0.8.4.9003
loaded via a namespace (and not attached):
[1] Rcpp_0.12.17 dbplyr_1.2.1 compiler_3.5.0 pillar_1.2.3 later_0.7.3
[6] plyr_1.8.4 bindr_0.1.1 base64enc_0.1-3 tools_3.5.0 digest_0.6.15
[11] jsonlite_1.5 tibble_1.4.2 nlme_3.1-137 lattice_0.20-35 pkgconfig_2.0.1
[16] rlang_0.2.1 psych_1.8.4 shiny_1.1.0 DBI_1.0.0 rstudioapi_0.7
[21] yaml_2.1.19 parallel_3.5.0 bindrcpp_0.2.2 stringr_1.3.1 dplyr_0.7.5
[26] httr_1.3.1 rappdirs_0.3.1 rprojroot_1.3-2 grid_3.5.0 tidyselect_0.2.4
[31] glue_1.2.0 R6_2.2.2 foreign_0.8-70 reshape2_1.4.3 purrr_0.2.5
[36] tidyr_0.8.1 magrittr_1.5 backports_1.1.2 promises_1.0.1 htmltools_0.3.6
[41] assertthat_0.2.0 mnormt_1.5-5 mime_0.5 xtable_1.8-2 httpuv_1.4.3
[46] config_0.3 stringi_1.1.7 lazyeval_0.2.1 broom_0.4.4
Well, with a bit of guessing I was able to solve my problem. I had to specify the "SPARK_HOME" environment manually.
spark_installed_versions()[1, 3] %>% spark_home_set()

ggparagraph is not displayed

I have problem with the function ggparagraph() from ggpubr package. Its content is not drawing. If I use the function:
example(ggparagraph)
The plot is drawing without any problem, but the "ggparagraph area" (below plot) is empty. The same problem is if I use custom scripts, where the ggparagraph is applied.
R does not print any error message. Where can be the problem?
My session info is:
sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 15063)
Matrix products: default
locale:
1 LC_COLLATE=Slovak_Slovakia.1250 LC_CTYPE=Slovak_Slovakia.1250
[3] LC_MONETARY=Slovak_Slovakia.1250 LC_NUMERIC=C
[5] LC_TIME=Slovak_Slovakia.1250
attached base packages:
1 stats graphics grDevices utils datasets methods base
other attached packages:
1 ggpubr_0.1.4 magrittr_1.5 gridExtra_2.2.1 dplyr_0.7.2
[5] purrr_0.2.3 readr_1.1.1 tidyr_0.6.3 tibble_1.3.3
[9] ggplot2_2.2.1 tidyverse_1.1.1
loaded via a namespace (and not attached):
1 Rcpp_0.12.12 cellranger_1.1.0 compiler_3.4.1 plyr_1.8.4
[5] bindr_0.1 forcats_0.2.0 tools_3.4.1 jsonlite_1.5
[9] lubridate_1.6.0 nlme_3.1-131 gtable_0.2.0 lattice_0.20-35
[13] pkgconfig_2.0.1 rlang_0.1.2 psych_1.7.5 parallel_3.4.1
[17] haven_1.1.0 bindrcpp_0.2 xml2_1.1.1 stringr_1.2.0
[21] httr_1.2.1 hms_0.3 cowplot_0.8.0 grid_3.4.1
[25] glue_1.1.1 R6_2.2.2 readxl_1.0.0 foreign_0.8-69
[29] reshape2_1.4.2 modelr_0.1.1 scales_0.4.1 rvest_0.3.2
[33] assertthat_0.2.0 mnormt_1.5-5 colorspace_1.3-2 labeling_0.3
[37] stringi_1.1.5 lazyeval_0.2.0 munsell_0.4.3 broom_0.4.2
Finally, I don't find where is the problem, but if I install this package from github (instead of CRAN), all paragraphs are rendered correctly.

Error training earth models in R - ForwardPassR

I'm using caret to train earth models like so:
test <- train(Y ~ X1+X2,table.needed,method = "earth")
which worked fine previously. However, now I am getting the following error:
Error in .C("ForwardPassR", fullset = as.integer(fullset), bx = matrix(0, :
"ForwardPassR" not available for .C() for package "earth"
This also happens when I call earth directly:
earth(Y ~ X1+X2,data = table.needed)
From other questions, I surmise that this is something with the underlying C - does anyone know how to fix the error and get the package running again?
I've attached the sessionInfo() call below:
R version 3.4.0 (2017-04-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server >= 2012 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] randomForest_4.6-12 broom_0.4.2 timekit_0.3.0 readr_1.1.1 hts_5.0
[6] matrixcalc_1.0-3 Matrix_1.2-9 SparseM_1.77 forecast_8.0 earth_4.5.0
[11] plotmo_3.3.3 TeachingDemos_2.10 plotrix_3.6-5 doParallel_1.0.10 iterators_1.0.8
[16] foreach_1.4.3 prophet_0.1.1 Rcpp_0.12.11 zoo_1.8-0 caretEnsemble_2.0.0
[21] caret_6.0-76 ggplot2_2.2.1 lattice_0.20-35 reshape2_1.4.2 dtplyr_0.0.2
[26] data.table_1.10.4 dplyr_0.5.0
loaded via a namespace (and not attached):
[1] tidyr_0.6.3 psych_1.7.5 assertthat_0.2.0 digest_0.6.12 lmtest_0.9-35
[6] R6_2.2.1 plyr_1.8.4 MatrixModels_0.4-1 stats4_3.4.0 rlang_0.1.1
[11] lazyeval_0.2.0 minqa_1.2.4 car_2.1-4 fracdiff_1.4-2 TTR_0.23-1
[16] nloptr_1.0.4 splines_3.4.0 lme4_1.1-13 foreign_0.8-68 stringr_1.2.0
[21] munsell_0.4.3 compiler_3.4.0 rstan_2.15.1 mnormt_1.5-5 mgcv_1.8-17
[26] nnet_7.3-12 tibble_1.3.3 gridExtra_2.2.1 quadprog_1.5-5 codetools_0.2-15
[31] MASS_7.3-47 ModelMetrics_1.1.0 grid_3.4.0 nlme_3.1-131 gtable_0.2.0
[36] DBI_0.6-1 magrittr_1.5 StanHeaders_2.15.0-1 scales_0.4.1 quantmod_0.4-9
[41] stringi_1.1.5 pbapply_1.3-2 tseries_0.10-41 timeDate_3012.100 xts_0.9-7
[46] tools_3.4.0 hms_0.3 pbkrtest_0.4-7 inline_0.3.14 colorspace_1.3-2
[51] quantreg_5.33
There is no version information about the earth package.
Anyway, I encounter with the same error with earth_4.5.0 and the error disappears when I update it to earth_4.5.1.
So I suggest you update or reinstall the package.

Plots do not appear in plot pane of updated version of RStudio

None of my plots are appearing in my plot pane or anywhere else. I've tried dev.off but it doesn't work and i've doubled checked that plots is checked off in global options. Help please!
dev.off()
Error in dev.off() : cannot shut down device 1 (the null device)
sessionInfo()
R version 3.2.5 (2016-04-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
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] splines stats graphics grDevices utils datasets methods base
other attached packages:
[1] tsne_0.1-3 RColorBrewer_1.1-2 mgcv_1.8-17 nlme_3.1-131 SpadeR_0.1.1
[6] psych_1.7.3.21 fpc_2.1-10 clue_0.3-53 FD_1.0-12 geometry_0.3-6
[11] magic_1.5-6 abind_1.4-5 ape_4.1 ade4_1.7-6 stringr_1.2.0
[16] readxl_0.1.1 DT_0.2 rerddap_0.3.4 vegan_2.4-3 lattice_0.20-35
[21] permute_0.9-4 scales_0.4.1 leaflet_1.1.0 raster_2.5-8 sp_1.2-4
[26] lubridate_1.6.0 dplyr_0.5.0 purrr_0.2.2 readr_1.1.0 tidyr_0.6.1
[31] tibble_1.3.0 ggplot2_2.2.1 tidyverse_1.1.1
loaded via a namespace (and not attached):
[1] httr_1.2.1 jsonlite_1.4 modelr_0.1.0 shiny_1.0.2 assertthat_0.2.0
[6] stats4_3.2.5 robustbase_0.92-7 digest_0.6.12 rvest_0.3.2 colorspace_1.3-2
[11] htmltools_0.3.5 httpuv_1.3.3 Matrix_1.2-8 plyr_1.8.4 broom_0.4.2
[16] haven_1.0.0 mvtnorm_1.0-6 xtable_1.8-2 nnet_7.3-12 lazyeval_0.2.0
[21] mnormt_1.5-5 magrittr_1.5 mime_0.5 mclust_5.2.3 ncdf4_1.16
[26] MASS_7.3-45 class_7.3-14 forcats_0.2.0 xml2_1.1.1 foreign_0.8-67
[31] tools_3.2.5 data.table_1.10.4 hms_0.3 trimcluster_0.1-2 kernlab_0.9-25
[36] munsell_0.4.3 cluster_2.0.6 grid_3.2.5 htmlwidgets_0.8 crosstalk_1.0.0
[41] labeling_0.3 gtable_0.2.0 flexmix_2.3-13 DBI_0.6-1 reshape2_1.4.2
[46] R6_2.2.0 prabclus_2.2-6 knitr_1.15.1 modeltools_0.2-21 stringi_1.1.5
[51] parallel_3.2.5 Rcpp_0.12.10 DEoptimR_1.0-8 diptest_0.75-7

Resources