I want to execute a R script in the background from the R console.
From the console , i usually run R script as source('~/.active-rstudio-document') I have to wait until the script is completed to go ahead with my rest of work. Instead of this i want R to be running in the background while i can continue with my work in the console. Also i should be somehow notified when R completes the source command. Is this possible in R ?
This might be quite useful as we often sees jobs taking long time.
PS - i want the source script to be running in the same memory space rather than a new one. Hence solutions like fork , system etc wont work for me. I am seeing if i can run the R script as a separate thread and not a separate process.
You can use
system()
and Rscript to run your script as an asynchronous background process:At the end of your script, you may save your objects with
save.image()
in order to load them later, and notify of its completion withcat()
:Hope this helps!