7

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.

3
  • 5
    You need to open another instance of R. Commented Sep 9, 2011 at 20:24
  • you can open another instance of R, but that you probably don't want to do I guess? Commented 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. Commented Dec 14, 2016 at 3:24

1 Answer 1

13

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.