Arun Arun - 2 months ago 7
R Question

How to call a R program from another R program?

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.

Answer

This should do

if(condition==X){
    source("program_A.R")
}else{
    source("program_B.R")
}