[R] Source awareness?

Bert Gunter gunter.berton at gene.com
Wed Oct 6 18:01:59 CEST 2010


?sys.call  ## and friends.

-- Bert

On Wed, Oct 6, 2010 at 8:49 AM, Ralf B <ralf.bierig at gmail.com> wrote:
> 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
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Bert Gunter
Genentech Nonclinical Biostatistics



More information about the R-help mailing list