RStudio suddenly extremely slow (12 march 2019) - r

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!

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

Error in generator$render using serve_site in R Blogdown

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

bookdown issue - knitr::include_graphics() - "Unable to load picture or PDF file" using image URL [duplicate]

This question already has an answer here:
RMarkdown: ! Package pdftex.def Error; online image not found?
(1 answer)
Closed 4 years ago.
ETA: I don't know if this makes a difference, but a couple days ago, I upgraded/updated my Linux packages. I have had issues in the past where that causes some issues in R/RStudio.
Strange happenings with bookdown. Just a couple days ago, bookdown was building my book beautifully. Now, when I try to build my book, it seems that knitr::include_graphics() is creating an issue, but only if it points to an image URL.
I created a new bookdown project to see if the problem would persist; it did. bookdown built Yihui's minimal example perfectly. Then, I used knitr::include_graphics() to add an image file in the book's directory. Again, in that case, bookdown built the book, and everything worked just right. But, when I changed the image location to a URL, the error message reads:
! LaTeX Error: File
`https://upload.wikimedia.org/wikipedia/commons/2/2e/Charle
s_Darwin_seated_crop' not found.
Error: Failed to compile testbook.tex. See testbook.log for more info.
Execution halted
Exited with status 1.
I am at a loss. The only thing I'm changing is whether the include_graphics() command is using a local file versus one at a URL. Any suggestions are appreciated. Here is my session info:
> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 18
Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics utils datasets grDevices
[6] methods base
other attached packages:
[1] ggthemr_1.1.0 mapdata_2.3.0
[3] maps_3.3.0 BRugs_0.9-0
[5] bookdown_0.8.2 blogdown_0.9
[7] rasterImage_0.3.0 plotrix_3.7-4
[9] rasterVis_0.45 latticeExtra_0.6-28
[11] lattice_0.20-38 gridExtra_2.3
[13] rgeos_0.4-2 dismo_1.1-4
[15] RColorBrewer_1.1-2 ggthemes_4.0.1
[17] R2OpenBUGS_3.2-3.2 popbio_2.4.4
[19] demogR_0.6.0 png_0.1-7
[21] jpeg_0.1-8 rnaturalearthhires_0.1.0
[23] rnaturalearthdata_0.1.0 rnaturalearth_0.1.0
[25] raster_2.8-4 rgdal_1.3-6
[27] scales_1.0.0 ggmap_2.7.904
[29] ggvis_0.4.4 rworldmap_1.3-7
[31] maptools_0.9-4 sp_1.3-1
[33] googlesheets_0.3.0 forcats_0.3.0
[35] stringr_1.3.1 dplyr_0.7.8
[37] purrr_0.2.5 readr_1.3.0
[39] tidyr_0.8.2 tibble_1.4.2
[41] ggplot2_3.1.0 tidyverse_1.2.1
loaded via a namespace (and not attached):
[1] nlme_3.1-137 bitops_1.0-6 sf_0.7-1
[4] lubridate_1.7.4 httr_1.4.0 tools_3.4.4
[7] backports_1.1.2 R6_2.3.0 spData_0.2.9.6
[10] DBI_1.0.0 lazyeval_0.2.1 colorspace_1.3-2
[13] withr_2.1.2 tidyselect_0.2.5 compiler_3.4.4
[16] cli_1.0.1 rvest_0.3.2 xml2_1.2.0
[19] hexbin_1.27.2 classInt_0.2-3 digest_0.6.18
[22] foreign_0.8-70 rmarkdown_1.11 pkgconfig_2.0.2
[25] htmltools_0.3.6 rlang_0.3.0.1 readxl_1.1.0
[28] rstudioapi_0.8 shiny_1.2.0 bindr_0.1.1
[31] generics_0.0.2 zoo_1.8-4 jsonlite_1.6
[34] magrittr_1.5 dotCall64_1.0-0 Rcpp_1.0.0
[37] munsell_0.5.0 yaml_2.2.0 stringi_1.2.4
[40] plyr_1.8.4 grid_3.4.4 parallel_3.4.4
[43] promises_1.0.1 crayon_1.3.4 haven_2.0.0
[46] hms_0.4.2 knitr_1.21 pillar_1.3.0
[49] boot_1.3-20 rjson_0.2.20 codetools_0.2-15
[52] glue_1.3.0 evaluate_0.12 modelr_0.1.2
[55] spam_2.2-0 httpuv_1.4.5 RgoogleMaps_1.4.3
[58] cellranger_1.1.0 gtable_0.2.0 assertthat_0.2.0
[61] xfun_0.4 mime_0.6 xtable_1.8-3
[64] broom_0.5.1 e1071_1.7-0 coda_0.19-2
[67] later_0.7.5 class_7.3-14 viridisLite_0.3.0
[70] fields_9.6 units_0.6-2 bindrcpp_0.2.2
Assuming you put
include_graphics("https://upload.wikimedia.org/wikipedia/commons/2/2e/Charles_Darwin_seated_crop.jpg")
in your document, then the issue is that LaTeX can't handle URLs. If you left the .jpg off, then that URL really doesn't exist.
You need to download the file and reference the local copy.

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