Error in generator$render using serve_site in R Blogdown - r

When I open my R Studio blogdown project and serve_site() it previews in the viewer and seems fine except that the content is not updated as it is in .Rmd files. It seems as though the preview site is getting stuck on the old .html files.
When saving an edited blogdown post in R Studio after executing serve_site() I expect the live preview to update.
Right now however, if I make a small edit to a post and click save, the preview fails and I get the following error that I can't make sense of or fix:
Error in generator$render(input_file = input_file, output_format = output_format, :
You probably should not knit the document in a blogdown project. Just call blogdown::serve_site() once per R session. See https://bookdown.org/yihui/blogdown/workflow.html. If you are sure you want to knit it and know what it means, set options(blogdown.allow_knit = TRUE).
Calls: <Anonymous> -> <Anonymous>
Execution halted
sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS 10.14.2
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shiny_1.2.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.0 compiler_3.4.3 later_0.8.0 prettyunits_1.0.2 remotes_2.0.2
[6] tools_3.4.3 testthat_2.0.1 digest_0.6.18 pkgbuild_1.0.2 pkgload_1.0.2
[11] jsonlite_1.6 evaluate_0.13 memoise_1.1.0 rlang_0.3.1 rstudioapi_0.9.0
[16] cli_1.0.1 curl_3.3 yaml_2.2.0 blogdown_0.10.5 xfun_0.4
[21] stringr_1.4.0 withr_2.1.2 knitr_1.21 desc_1.2.0 fs_1.2.6
[26] devtools_2.0.1 rprojroot_1.3-2 glue_1.3.0 R6_2.4.0 processx_3.2.1
[31] rmarkdown_1.11 bookdown_0.9 sessioninfo_1.1.1 servr_0.12 callr_3.1.1
[36] magrittr_1.5 backports_1.1.2 ps_1.3.0 promises_1.0.1 htmltools_0.3.6
[41] usethis_1.4.0 rsconnect_0.8.13 assertthat_0.2.0 xtable_1.8-3 mime_0.6
[46] httpuv_1.4.5.1 stringi_1.3.1 miniUI_0.1.1.1 crayon_1.3.4

Related

Double question mark (??) help search not working in RStudio (and RStudio only)

strange behaviour I noticed in my RStudio installation:
Help search via the double question mark (e.g., ??gg) does not work in RStudio. It gives me "No results found" in the Help pane.
Help search via the upper search field in the Help pane works as intended and returns results for the example search above.
?? works in the Mac OS R GUI ("R.app"), it opens a browser tab with the results page.
Single question mark ? works also in RStudio (but of course only with exact matches to names).
Does anybody know how to resolve this? Thanks!
EDIT: My sessionInfo():
R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] jsonlite_1.6 scales_1.0.0 tidyr_0.8.3 ggplot2_3.2.0 koRpus.lang.de_0.1-1 koRpus_0.11-5
[7] sylly_0.1-5 readxl_1.3.1 data.table_1.12.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.1 highr_0.8 cellranger_1.1.0 pillar_1.4.1 compiler_3.6.0 tools_3.6.0 zeallot_0.1.0
[8] digest_0.6.19 tibble_2.1.3 gtable_0.3.0 pkgconfig_2.0.2 rlang_0.4.0 cli_1.1.0 rstudioapi_0.10
[15] curl_3.3 yaml_2.2.0 xfun_0.8 knitr_1.23 withr_2.1.2 dplyr_0.8.1 vctrs_0.1.0
[22] grid_3.6.0 tidyselect_0.2.5 sylly.de_0.1-2 glue_1.3.1 R6_2.4.0 fansi_0.4.0 purrr_0.3.2
[29] magrittr_1.5 backports_1.1.4 fortunes_1.5-4 assertthat_0.2.1 colorspace_1.4-1 labeling_0.3 utf8_1.1.4
[36] lazyeval_0.2.2 munsell_0.5.0 crayon_1.3.4

RStudio suddenly extremely slow (12 march 2019)

I ran into the super slow problem last Friday, then for 3 days it worked, and now it is back again.
At first I thought it was the internet connection, but that seems not to be the case.
I've already tried various things such as:
- reinstall RStudio
- Reboot PC several times
- Use a different internet network
- remove all .RData and .RHistory files that I could find
but it is still going at crawl speed.
This morning it was running as expected, a few hours later at work, same laptop, it is super slow again.
I have virtually no other programs open, and it is slow straight from the start after a reboot every single time.
Does anyone have any suggestions how to figure out what is causing this, and how to solve it?
I'm running Version 1.1.463 of RStudio on a windows 7 professional.
sessionInfo()
R version 3.5.2 (2018-12-20)
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=Dutch_Netherlands.1252 LC_CTYPE=Dutch_Netherlands.1252 LC_MONETARY=Dutch_Netherlands.1252 LC_NUMERIC=C
[5] LC_TIME=Dutch_Netherlands.1252
attached base packages:
[1] grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] flowPeaks_1.26.0 PerformanceAnalytics_1.5.2 xts_0.11-2 zoo_1.8-4 gtools_3.8.1
[6] lemon_0.4.3 gridExtra_2.3 pryr_0.1.4 scales_1.0.0 stringi_1.3.1
[11] V8_2.0 taRifx_1.0.6.1 webshot_0.5.1 broom_0.5.1 forcats_0.4.0
[16] stringr_1.4.0 dplyr_0.8.0.1 purrr_0.3.1 readr_1.3.1 tibble_2.0.1
[21] tidyverse_1.2.1 randomForest_4.6-14 yaml_2.2.0 plyr_1.8.4 colourpicker_1.0
[26] DT_0.5 tidyr_0.8.3 htmlwidgets_1.3 plotly_4.8.0 ggplot2_3.1.0
[31] bit64_0.9-7 bit_1.1-14 lubridate_1.7.4 shinyWidgets_0.4.5 shinyjqui_0.3.2
[36] shinyjs_1.0 shinydashboard_0.7.1 shinyBS_0.61 data.table_1.12.0 shiny_1.2.0
loaded via a namespace (and not attached):
[1] httr_1.4.0 jsonlite_1.6 viridisLite_0.3.0 modelr_0.1.4 assertthat_0.2.0 cellranger_1.1.0 pillar_1.3.1 backports_1.1.3
[9] lattice_0.20-38 quadprog_1.5-5 glue_1.3.0 digest_0.6.18 promises_1.0.1 rvest_0.3.2 colorspace_1.4-0 htmltools_0.3.6
[17] httpuv_1.4.5.1 pkgconfig_2.0.2 haven_2.1.0 xtable_1.8-3 later_0.8.0 generics_0.0.2 withr_2.1.2 lazyeval_0.2.1
[25] cli_1.0.1 magrittr_1.5 crayon_1.3.4 readxl_1.3.0 mime_0.6 nlme_3.1-137 xml2_1.2.0 tools_3.5.2
[33] hms_0.4.2 munsell_0.5.0 compiler_3.5.2 rlang_0.3.1 rstudioapi_0.9.0 crosstalk_1.0.0 miniUI_0.1.1.1 gtable_0.2.0
[41] codetools_0.2-15 curl_3.3 reshape2_1.4.3 R6_2.4.0 knitr_1.22 Rcpp_1.0.0 xfun_0.5 tidyselect_0.2.5
I was having the same problems in my RStudio Desktop IDE. The main problem was that it was extremely slow to start the IDE and perform trivial tasks like opening a script or using the console to perform basic calculations. Doing some research, this is what helped me:
Resetting RStudio Desktop's State.
Running a Diagnostic Report. My issue was that my HOME environmental variable was set to a network/shared drive (i.e. OneDrive).
I fixed this by setting my HOME env variable to a local directory. Check this solution. Check this thread for more background.
Good luck!

Why devtools::document fails with unclear C++ error message?

I have a vignette that I can build using devtools::build_vignettes() but when I try to build the source package (RStudio/Build/build source package) it fails when executing devtools::document(roclets=c('rd', 'collate', 'namespace', 'vignette')) with the following error message:
R(32119,0x7fff7437f000) malloc: *** error for object 0x7fff74dc0c30: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Exited with status 6.
This package uses Rcpp but I am definitely not an expert in Cpp and don't understand at all what is going on. I can use the package locally with no troubles.
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/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
loaded via a namespace (and not attached):
[1] Rcpp_1.0.0 rstudioapi_0.8 knitr_1.20 magrittr_1.5 usethis_1.4.0 devtools_2.0.1
[7] pkgload_1.0.2 R6_2.3.0 rlang_0.3.0.1 tools_3.5.1 pkgbuild_1.0.2 sessioninfo_1.1.1
[13] cli_1.0.1 withr_2.1.2 htmltools_0.3.6 remotes_2.0.2 yaml_2.2.0 assertthat_0.2.0
[19] digest_0.6.18 rprojroot_1.3-2 crayon_1.3.4 processx_3.2.0 callr_3.0.0 clisymbols_1.2.0
[25] base64enc_0.1-3 fs_1.2.6 ps_1.2.1 evaluate_0.12 glue_1.3.0 memoise_1.1.0
[31] rmarkdown_1.10 compiler_3.5.1 desc_1.2.0 backports_1.1.2 prettyunits_1.0.2

Shiny deployment problem, hangs at: Uploading bundle for application: 413154

My shiny app works in my viewer but hangs when I deploy the app to shinyapps.io. In the files deployed to shinyapps.io are global.R, app.R, app.Rproj and /data (directory containing a subdirectory of 300 pdf files in total of about 800mb). I read the pdf data text and create a text analysis in global.R.
When trying to deploy all it does is
something like: preparing... DONE
Then it hangs forever on Uploading bundle for application: 413154..
> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/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] bindrcpp_0.2.2 DT_0.4 visdat_0.1.0 tidytext_0.1.8 broom_0.4.4 quanteda_1.3.4 tm_0.7-5
[8] NLP_0.1-11 pdftools_1.8 forcats_0.3.0 stringr_1.3.1 dplyr_0.7.6 purrr_0.2.5 readr_1.1.1
[15] tidyr_0.8.1 tibble_1.4.2 ggplot2_3.0.0 tidyverse_1.2.1 shiny_1.1.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.17 lubridate_1.7.4 lattice_0.20-35 assertthat_0.2.0 digest_0.6.15 psych_1.8.4
[7] mime_0.5 slam_0.1-43 R6_2.2.2 cellranger_1.1.0 plyr_1.8.4 httr_1.3.1
[13] pillar_1.2.2 rlang_0.2.0.9001 lazyeval_0.2.1 readxl_1.1.0 rstudioapi_0.7 data.table_1.10.4-3
[19] Matrix_1.2-14 labeling_0.3 foreign_0.8-70 htmlwidgets_1.2 munsell_0.4.3 janeaustenr_0.1.5
[25] spacyr_0.9.91 compiler_3.4.3 httpuv_1.4.3 modelr_0.1.2 pkgconfig_2.0.1 mnormt_1.5-5
[31] htmltools_0.3.6 tidyselect_0.2.4 crayon_1.3.4 withr_2.1.2 later_0.7.2 SnowballC_0.5.1
[37] grid_3.4.3 nlme_3.1-137 jsonlite_1.5.9000 xtable_1.8-2 gtable_0.2.0 magrittr_1.5
[43] tokenizers_0.2.1 scales_0.5.0.9000 RcppParallel_4.4.1 cli_1.0.0 stringi_1.2.4 reshape2_1.4.3
[49] promises_1.0.1 xml2_1.2.0 stopwords_0.9.0 fastmatch_1.1-0 tools_3.4.3 glue_1.2.0
[55] hms_0.4.2 rsconnect_0.8.8 parallel_3.4.3 yaml_2.2.0 colorspace_1.3-2 rvest_0.3.2
[61] bindr_0.1.1 haven_1.1.1
If you need additional things to help me, feel free to ask! Any help much appreciated!
It might seem elementary, but the problem is the size. I've deployed an app whose folder contained only a few KB's worth of files, and it took a pretty long time at the same Uploading bundle for application: xxxxx. Your app might also need a lot of libraries, as you have 19 loaded.

How to open working directory directly from R console?

How can I open my getwd() folder directly from the R console? This is useful if I want to see something I've recently just exported there. A google search has revealed nothing and I don't have the capability to build a function.
If you actually want a file browser you could create a function to open the directory. This is done differently based on the operating system you're using but this should cover most bases
opendir <- function(dir = getwd()){
if (.Platform['OS.type'] == "windows"){
shell.exec(dir)
} else {
system(paste(Sys.getenv("R_BROWSER"), dir))
}
}
If you don't need it to be cross platform you can reduce it down to just the code for your OS. But if you just want to view the files in a given directory then using dir should be good enough.
You can use dir() or list.files() to display the files in the current working directory or file.choose() to browse the directory and choose a file. All three default to the current working directory.
I'd suggest using:
utils::browseURL(getwd())
Posting an answer because the above function did not work for me - got around it buusing a macOS terminal command via a system call from within R (session info below).
Function
opendir <- function(directory = getwd()){
system(sprintf('open %s', shQuote(directory)))
}
Session Info
> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8
attached base packages:
[1] stats graphics grDevices utils
[5] datasets methods base
other attached packages:
[1] here_0.1 htmlwidgets_1.3
[3] openxlsx_4.1.0.1 tictoc_1.0
[5] plotly_4.9.0 jsonlite_1.6
[7] ggplot2_3.1.1 lubridate_1.7.4
[9] httr_1.4.0 data.table_1.12.2
loaded via a namespace (and not attached):
[1] zip_2.0.2 Rcpp_1.0.1
[3] RColorBrewer_1.1-2 later_0.8.0
[5] pillar_1.4.0 compiler_3.6.0
[7] plyr_1.8.4 tools_3.6.0
[9] digest_0.6.19 packrat_0.5.0
[11] tibble_2.1.1 gtable_0.3.0
[13] viridisLite_0.3.0 pkgconfig_2.0.2
[15] rlang_0.3.4 shiny_1.3.2
[17] rstudioapi_0.10 crosstalk_1.0.0
[19] yaml_2.2.0 withr_2.1.2
[21] dplyr_0.8.1 stringr_1.4.0
[23] rprojroot_1.3-2 grid_3.6.0
[25] tidyselect_0.2.5 glue_1.3.1
[27] R6_2.4.0 processx_3.3.1
[29] purrr_0.3.2 tidyr_0.8.3
[31] magrittr_1.5 ps_1.3.0
[33] promises_1.0.1 backports_1.1.4
[35] scales_1.0.0 htmltools_0.3.6
[37] assertthat_0.2.1 xtable_1.8-4
[39] mime_0.6 colorspace_1.4-1
[41] httpuv_1.5.1 labeling_0.3
[43] stringi_1.4.3 lazyeval_0.2.2
[45] munsell_0.5.0 crayon_1.3.4

Resources