Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call a R program from another R program?

Tags:

r

Is it possible to call a R program with in a R program?

Say for example, I am looking for something like this:

If condition == X{
   CALL "Pgm A"
  } else {
     CALL "Pgm B"
 }

This kind of syntax I have used in C. Is there a way similar in R?

Thank you.

like image 637
Arun Avatar asked Mar 10 '16 05:03

Arun


People also ask

Can you run 2 R scripts at the same time?

Run multiple R scripts from the command line in parallelTo parallelize this you can run the command mentioned above multiple times and only change the tiling arguments. Multiple R session on multiple cores will process your jobs. You can also create a shell script for doing this.

How do I run an R code in line by line?

On your keyboard: press CTRL+ENTER . The line will be executed, the cursor jumps into the next line. Again, press CTRL+ENTER to execute the next line … and so far, and so on.


1 Answers

This should do

if(condition==X){
    source("program_A.R")
}else{
    source("program_B.R")
}
like image 163
Ujjwal Kumar Avatar answered Sep 22 '22 13:09

Ujjwal Kumar