shiny runs undesirable scripts on R folder - r

This issue shook me. Lets a minimal reproducible example:
On RStudio, create a New Project... Choose Shiny Web App. Check that sample app runs well.
Create inside the standard R folder, to put all your *.R scripts.
Create a dummy script inside the R folder that fails, but you do not want run yet. For example
str(do_not_exist) ## foo.R
4.Run the App again. Now, the App fails
> runApp()
Error in str(do_not_exist) : objeto 'do_not_exist' no encontrado
Why Shiny runs undesirable scripts? They are OUT of the root directory.
I am not finding ways to save scripts that are not functions within the project.
This is my R Session
> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=Spanish_Argentina.1252 LC_CTYPE=Spanish_Argentina.1252
[3] LC_MONETARY=Spanish_Argentina.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Argentina.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] tidyr_1.1.3 dplyr_1.0.5 openxlsx_4.2.3.9000 shiny_1.6.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.6 magrittr_2.0.1 tidyselect_1.1.0 xtable_1.8-4
[5] R6_2.5.0 rlang_0.4.10 fastmap_1.1.0 fansi_0.4.2
[9] tools_4.0.5 utf8_1.2.1 DBI_1.1.1 withr_2.4.2
[13] htmltools_0.5.1.1 ellipsis_0.3.1 assertthat_0.2.1 digest_0.6.27
[17] tibble_3.1.1 lifecycle_1.0.0 crayon_1.4.1 zip_2.1.1
[21] purrr_0.3.4 later_1.1.0.1 vctrs_0.3.7 promises_1.2.0.1
[25] glue_1.4.2 mime_0.10 stringi_1.5.3 compiler_4.0.5
[29] pillar_1.6.0 generics_0.1.0 httpuv_1.5.5 pkgconfig_2.0.3

See here. One option is options(shiny.autoload.r = FALSE).

Related

RStudio session crashes on running nloptr

I am trying to run a non-linear constrained optimisation using the nloptr package. When I run the optimisation the Rstudio session crashes. The log files don't seem to capture this crash. The last log file is from some weeks back. The diagnostics report also shows this as the last error:
31 Jul 2021 12:49:50 [rsession-dhruvakaggarwal] ERROR system error 2
(No such file or directory)
[path=/Volumes/GoogleDrive/.shortcut-targets-by-id/1uELoLTtQ0-MVlZj5loA1k2gZAdJlDODV/SEA-LBL/Dhruvak];
OCCURRED AT: rstudio::core::Error
rstudio::core::FilePath::makeCurrentPath(bool) const
/Users/rstudio/rstudio/src/cpp/core/FilePath.cpp:1037; LOGGED FROM:
virtual void
rstudio::session::modules::rmarkdown::notebook::ChunkExecContext::connect()
/Users/rstudio/rstudio/src/cpp/session/modules/rmarkdown/NotebookExec.cpp:202
When I request logs it shows this:
The session does not crash when the optimisation problem is run on a substantially smaller sample dataset, which might point to limited RAM on the system? I'm running it on an 8GB system, but I've tried it on a 32GB system and it still crashes. Curiously, it doesn't crash on another 16GB system.
Session info:
R version 4.0.0 (2020-04-24)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS 10.16
Matrix products: default
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
loaded via a namespace (and not attached):
[1] Rcpp_1.0.7 compiler_4.0.0 pillar_1.6.2 bitops_1.0-6 tools_4.0.0 lifecycle_1.0.0 tibble_3.0.1
[8] gtable_0.3.0 lattice_0.20-41 pkgconfig_2.0.3 rlang_0.4.11 Matrix_1.2-18 cli_2.0.2 DBI_1.1.0
[15] rstudioapi_0.11 binman_0.1.1 dplyr_1.0.7 generics_0.0.2 vctrs_0.3.8 askpass_1.1 mitools_2.4
[22] caTools_1.18.0 tidyselect_1.1.0 grid_4.0.0 glue_1.4.0 R6_2.4.1 processx_3.4.2 fansi_0.4.1
[29] XML_3.99-0.3 survival_3.1-12 RSelenium_1.7.7 purrr_0.3.4 ggplot2_3.3.0 semver_0.2.0 magrittr_1.5
[36] ps_1.3.2 scales_1.1.0 ellipsis_0.3.2 splines_4.0.0 assertthat_0.2.1 colorspace_1.4-1 utf8_1.1.4
[43] survey_4.0 openssl_1.4.1 munsell_0.5.0 wdman_0.2.5 crayon_1.3.4
I am unable to figure out the cause for this. Please help.

Knitr keeps executing and cannot be cancelled after error

Every time I run into an error while knitting a script that stops execution, RStudio behaves in a weird way: In the R markdown tab it reads in red that the execution is stopped but in the R markdown tab I see the continuing progress circle still moving, suggesting that knitting is still ongoing. Also on the right hand I see that "stop" sign but clicking on it also does not stop executing. I can still write text in the script but I can no longer execute the script and can also not kick off a new knitting attempt.
The only way of going back to normal is top close Rstudio and re-start it. That means, everytime I run into any kind of error while knitting I have to restart Rstudio. This does not occur on my private PC with the same scripts.
I have installed a new version of Rstudio (the new 1.4 Preview) and I have re-installed R Markdown. Do you have any tips?
edit:
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)
Matrix products: default
Random number generation:
RNG: Mersenne-Twister
Normal: Inversion
Sample: Rounding
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
other attached packages:
[1] rmarkdown_2.5
loaded via a namespace (and not attached):
[1] rstudioapi_0.13 knitr_1.30 magrittr_2.0.1 tidyselect_1.1.0
[5] R6_2.5.0 rlang_0.4.9 dplyr_1.0.2 tools_4.0.3
[9] xfun_0.19 pacman_0.5.1 htmltools_0.5.0 ellipsis_0.3.1
[13] yaml_2.2.1 digest_0.6.27 tibble_3.0.4 lifecycle_0.2.0
[17] crayon_1.3.4 purrr_0.3.4 tidyr_1.1.2 vctrs_0.3.5
[21] clisymbols_1.2.0 glue_1.4.2 evaluate_0.14 compiler_4.0.3
[25] pillar_1.4.7 generics_0.1.0 pkgconfig_2.0.3 tidylog_1.0.2

RStudio - Markdown Crash: Error in (function (srcref) : unimplemented type (29) in 'eval'

My RStudio crashed a number of times with the following error:
Error in (function (srcref) : unimplemented type (29) in 'eval'
The similarities where this has happened were:
I was working in a Markdown Notebook
I believe it was always when I selected the "Run all chunks above" command
I had run some code chunks in the current session before (so it wasn't upon starting work)
The error was always displayed just before the RStudio session aborted. I lose all my data and variables in the environment, but most of the code seems to be recoverable.
Anyone with an idea of what might cause this or how to deal with it?
Here my SessionInfo
R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.12.8 forcats_0.5.0 stringr_1.4.0 dplyr_0.8.5 purrr_0.3.4 readr_1.3.1
[7] tidyr_1.0.2 tibble_3.0.0 ggplot2_3.3.0 tidyverse_1.3.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.4.6 cellranger_1.1.0 pillar_1.4.3 compiler_4.0.0 dbplyr_1.4.3 tools_4.0.0 packrat_0.5.0
[8] lubridate_1.7.8 jsonlite_1.6.1 lifecycle_0.2.0 nlme_3.1-147 gtable_0.3.0 lattice_0.20-41 pkgconfig_2.0.3
[15] rlang_0.4.5 reprex_0.3.0 cli_2.0.2 DBI_1.1.0 rstudioapi_0.11 haven_2.2.0 xfun_0.13
[22] withr_2.2.0 xml2_1.3.1 httr_1.4.1 knitr_1.28 fs_1.4.1 hms_0.5.3 generics_0.0.2
[29] vctrs_0.2.4 grid_4.0.0 tidyselect_1.0.0 glue_1.4.0 R6_2.4.1 fansi_0.4.1 readxl_1.3.1
[36] modelr_0.1.6 magrittr_1.5 backports_1.1.6 scales_1.1.0 ellipsis_0.3.0 rvest_0.3.5 assertthat_0.2.1
[43] colorspace_1.4-1 stringi_1.4.6 munsell_0.5.0 broom_0.5.6 crayon_1.3.4
I sadly can't give you a reproducible example, but this is a screenshot of the last time it happened:
And the next time following a fairly simple ggplot command:
You might try updating Rstudio.
I had similar messages that started to occur after I updated to version 4.0.0 of R. These errors were occurring with code that presented no problems on previous versions of R. I could run the code line by line with Ctrl-Enter with no error, but running the whole chunk would be a problem.
The issue went away when I updated Rstudio from Version 1.1.463 to 1.2.5042.

eval trouble into R package

I have been making a package to upload to CRAN, but I have a little trouble.
If you go to the website, https://github.com/elflacosebas/migraR, you will find the package.
You can run the example to test it.
The problem comes when I want to avoid the attach and perform the best_migramod function. Then, it will use inside fit_migramod, which uses a class named Migramodel.
You can run the example now without the line codes below:
colnames(data1) <- c("x","y")
attach(data1)
The error I get says:
Error in eval(.self$expr, c(as.list(p), as.list(data))) :
object 'x' not finded
I have tried using attach and detach to solve it into the best_migradmod function but it doesn't work. I understand it is a matter of environment as this post says as well.
Error in eval(expr, envir, enclos) : object not found
Where shoud I put the attach? or the other operators, or should I modify the data file? or
Thanks a lot for the hint!!
In my laptop work the example without the two lines that you mentioned
sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
Random number generation:
RNG: Mersenne-Twister
Normal: Inversion
Sample: Rounding
locale:
[1] LC_COLLATE=Spanish_Colombia.1252 LC_CTYPE=Spanish_Colombia.1252 LC_MONETARY=Spanish_Colombia.1252
[4] LC_NUMERIC=C LC_TIME=Spanish_Colombia.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] migraR_0.1.2 devtools_2.2.1 usethis_1.5.1 dplyr_0.8.3
loaded via a namespace (and not attached):
[1] Rcpp_1.0.2 rstudioapi_0.10 magrittr_1.5 tidyselect_0.2.5 pkgload_1.0.2 R6_2.4.0
[7] rlang_0.4.2 tools_3.6.0 pkgbuild_1.0.6 sessioninfo_1.1.1 cli_1.1.0 withr_2.1.2
[13] remotes_2.1.0 ellipsis_0.3.0 rprojroot_1.3-2 assertthat_0.2.1 digest_0.6.20 tibble_2.1.3
[19] crayon_1.3.4 processx_3.4.1 purrr_0.3.3 callr_3.3.1 fs_1.3.1 ps_1.3.0
[25] curl_4.0 testthat_2.3.1 memoise_1.1.0 glue_1.3.1 compiler_3.6.0 pillar_1.4.2
[31] backports_1.1.4 desc_1.2.0 prettyunits_1.0.2 pkgconfig_2.0.2

Rhandsontable displays on a locally deployed app, but not on app displayed in AWS EC2 Ubuntu 18.04 server

I'm trying to deploy on a private server an app that allows me to edit an RHandsontable object. For privacy reasons I cannot be showing a demonstration here.
I have successfully tested my app locally, but when I deploy it on my server the RHandsontable doesn't display, and the app "screen goes gray" after I start interacting there, so it doesn't allow any further interactions there.
This is how it looks on my Windows 10 browser. You can even see a 2 rhandsontables (that are empty because it has no selection whatsoever), that can be edited. The "Guardar" button is currently a dummy.
This is how it looks on AWS Ubuntu 18.04 Shiny Server. No rhandsontable loads (though the button loads). Same script, just different directories. I verified that the data loaded into both shiny apps were the same. You can also appreciate that the dummy button "Guardar" still appears.
I tried the same rendering equivalent data.tables from both the shiny and DT packages, leading to the same results as shown above.
Also, when I check my server logs at /var/log/shiny-server/ no issue arises (eg.: missing packages, broken code, etc). Last log goes as follows:
Attaching package: ‘dplyr’
The following objects are masked from ‘package:stats’:
filter, lag
The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union
Attaching package: ‘DT’
The following objects are masked from ‘package:shiny’:
dataTableOutput, renderDataTable
Listening on http://127.0.0.1:41757
This suggests me that I have a compatibility / interaction issue that arises in Shiny Server or in Ubuntu that doesn't arise in my PC.
I have seen different sources in Stack Overflow and in jrowen's GitHub page without any success, and I'd like to know if I'm missing anything.
There's a minor difference between R version between both machines (my Ubuntu VM is fresh, so some packages are updated). This could also cause a problem, but I'm not positive this could be the reason.
I also installed JRE on both instances (I also thought this could be caused due to a Java issue that I haven't fixed properly). Running java -version on my VM yields
openjdk version "10.0.2" 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed mode)
My personal computer is a Windows 10 Machine. Details:
R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
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 base
other attached packages:
[1] readxl_1.1.0 lubridate_1.7.4 mailR_0.4.1 forcats_0.3.0
[5] stringr_1.3.1 purrr_0.2.5 readr_1.1.1 tidyr_0.8.1
[9] tibble_2.0.1 ggplot2_3.0.0.9000 tidyverse_1.2.1 DBI_1.0.0
[13] RODBC_1.3-15 DT_0.4 rhandsontable_0.3.7 Cairo_1.5-9
[17] openxlsx_4.1.0 knitr_1.20 dplyr_0.8.0.1 shiny_1.1.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.0 lattice_0.20-35 assertthat_0.2.0 digest_0.6.15 mime_0.5
[6] R6_2.2.2 cellranger_1.1.0 plyr_1.8.4 backports_1.1.2 evaluate_0.10.1
[11] httr_1.3.1 highr_0.7 pillar_1.3.1 rlang_0.3.1 lazyeval_0.2.1
[16] rstudioapi_0.7 R.oo_1.22.0 R.utils_2.8.0 rmarkdown_1.11 htmlwidgets_1.2
[21] munsell_0.5.0 broom_0.5.0 compiler_3.5.0 httpuv_1.4.4.1 modelr_0.1.2
[26] pkgconfig_2.0.2 htmltools_0.3.6 tidyselect_0.2.5 crayon_1.3.4 withr_2.1.2
[31] later_0.7.3 R.methodsS3_1.7.1 grid_3.5.0 nlme_3.1-137 jsonlite_1.5
[36] xtable_1.8-2 gtable_0.2.0 magrittr_1.5 scales_0.5.0 zip_1.0.0
[41] cli_1.0.1 stringi_1.1.7 promises_1.0.1 xml2_1.2.0 tools_3.5.0
[46] glue_1.3.0 hms_0.4.2 rsconnect_0.8.12 yaml_2.1.19 colorspace_1.3-2
[51] rvest_0.3.2 rJava_0.9-10 haven_1.1.2
The Ubuntu 18.04 machine goes as follows:
R version 3.5.3 (2019-03-11)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.2 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
locale:
[1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8
[4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8
[7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] readxl_1.3.1 DT_0.5 rhandsontable_0.3.7
[4] knitr_1.22 shiny_1.2.0 dplyr_0.8.0.1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.1 magrittr_1.5 tidyselect_0.2.5 xtable_1.8-3
[5] R6_2.4.0 rlang_0.3.3 tools_3.5.3 xfun_0.5
[9] htmltools_0.3.6 assertthat_0.2.1 digest_0.6.18 tibble_2.1.1
[13] crayon_1.3.4 purrr_0.3.2 later_0.8.0 htmlwidgets_1.3
[17] promises_1.0.1 glue_1.3.1 mime_0.6 cellranger_1.1.0
[21] compiler_3.5.3 pillar_1.3.1 jsonlite_1.6 httpuv_1.5.0
[25] pkgconfig_2.0.2
In advance, thanks very much for your help. Please clarify at comments if you need any extra information (that I can provide).
Edit: I checked as well outputting data.tables instead of rhandsontables both locally and on Ubuntu and failed as well rendering only on my Ubuntu VM.
For anyone interested in my problem, it was actually related to a firewall issue, not to a server-side or compatibility issue.
When I accessed my application from a network that wasn't my organization's (i.e. my cell phone's shared internet or home network) I had no problem at all.

Resources