I have a big looping script running in R-GUI and was curious if I can concurrently run other scripts in the same R-GUI session or can I open another session of R? Any suggestions would be great thanks.
-
5You need to open another instance of R.Dirk is no longer here– Dirk is no longer here2011-09-09 20:24:34 +00:00Commented Sep 9, 2011 at 20:24
-
you can open another instance of R, but that you probably don't want to do I guess?Tomas– Tomas2011-09-09 20:24:54 +00:00Commented Sep 9, 2011 at 20:24
-
I do run multiple R scripts. I suggest to find out how many drives (processors?) your computer has, and it doesn't slow them down much to run e.g. 3 scripts if you have 4 hard drives (processors?). Make sure they are using different directories to source and store all info for each one. Put copies all the info they need (and make) within the directory they are using, so the program does not have to leave the directory for anything except for uploaded, unchanging packages.gayle– gayle2016-12-14 03:24:52 +00:00Commented Dec 14, 2016 at 3:24
1 Answer
I often have several different instances of R running on my computer on different projects. While one is processing a script or doing a long run I can use a different one to work on another project.
While it is possible to have the same R session running multiple things concurrently (I have done this using the tcltk package) it is generally not advisable as the different projects could all access/change the same global environment which could mess things up. With multiple sessions they each have their own global environment (just be careful that they don't overwrite files if working from the same folder/directory).
There are also packages that will help with parallel processing which may be more what you are interested in. If each step of your loop runs independent of the others (step i+1 does not depend on the results of step i) and you have multiple processors (or multiple computers) then sometimes the parallel processing can help. See the HighPerformanceComputing task view on CRAN for descriptions of these packages.