[R] Source awareness?

Ralf B ralf.bierig at gmail.com
Wed Oct 6 17:49:47 CEST 2010


Here the general (perhaps silly question) first: Is it possible for a
script to find out if it was sourced by another script or run
directly?

Here a small example with two scripts:

# script A
print ("This is script A")

# script B
source("C:/scriptA.R")
print ("This is script B")

I would like to modify script A in a way so that it only outputs 'This
is script A' if it was called directly, but keeps quiet in the other
case.

In addition to that, is it possible to access the stack of script
calls from the environment?

Ralf



More information about the R-help mailing list