Dear R users,
 
Suppose I have 2 R script files: 'test1.R' and 'test2.R' and one R file 'main.R' which sources each of them. I wonder if there is a way to skip rest of code in 'test1.R' once a condition is met but still continue to run rest of script from the 'main'R' file.
 
A simple example is shown below. I hope only 'message1' and 'message3' can be shown up without using if(...) else statement for skipped part in 'test1.R'.
 
#main.R:
source("test1.R")
source("test2.R")
=======================================
#test1.R
# In this example the goal is to skip executing the line of print("message2").
# without using if() else statement.
x <- TRUE
if (x) {
    print("message1")
    q() # want to skip rest of code in test1.R ONLY
}
# lots of lines can start from here.
print("message2")
=======================================
#test2.R
print("message3")
 
 
Thank you.
Ming-chung Li

	[[alternative HTML version deleted]]


