CMD R

How to run R script from another R script and use as a source

Here is a solution with running R script from another R script and using as a source. It comes handy when R script uses different bit version R, or you want to continue script execution with another one.

Run R script from another R script

You can execute R script as you would normally do by using the Windows command line. If your R version is different, then change the path to Rscript.exe. Use double quotes if the file path contains space.

Source R script from another R script

In this way, you will get R script results (for example, data frames, etc.) and it is also possible to continue working with them.

How to run 32 bit R script from 64 bit RStudio and use as a source

It is workaround where first of all you should prepare your 32 bit script to achieve results. Latest RStudio versions come only in 64 bit version, and if you are using some specific ODBC with 32 bit driver, that will help.

In the first script, save necessary objects in RData or another format. In this case, in the working directory. You can check your working directory location with function getwd().

It the second script execute the first script with 32bit R and load RData file.



0 comments on “How to run R script from another R script and use as a source

Leave a Reply

Your email address will not be published. Required fields are marked *