I\'m trying to call a simple python script from within R using system2(). I\'ve read some information I found vague that said if \'too much\' memory is used, it won\'t work.
RStudio has this undocumented rs.restartR()
which is supposed to do just that: restarting R.
However, it does not unload the packages that were loaded, nor does it clean the environment, so that I have some doubts about if it restarts R at all.
Have you tried embedding the function call within the apply function, rather than a for loop?
I've had some pieces of code that ran the system out of memory in a for loop run perfectly with apply. It might help?
In Rstudio, you can restart the R session by:
command/ctrl + shift + F10
You can also use:
.rs.restartR()
If you use RStudio, use the menu item Session > Restart R or the associated keyboard shortcut Ctrl+Shift+F10
(Windows and Linux) or Command+Shift+F10
(Mac OS). Additional keyboard shortcuts make it easy to restart development where you left off, i.e. to say “re-run all the code up to HERE”:
In an R script, use Ctrl+Alt+B
(Windows and Linux) or Command+Option+B
(Mac OS)
In R markdown, use Ctrl+Alt+P
(Windows and Linux) or Command+Option+P
(Mac OS)
If you run R from the shell, use Ctrl+D
or q()
to quit, then restart R.