[R] Source inside source
Duncan Temple Lang
duncan at wald.ucdavis.edu
Tue Jul 17 00:46:35 CEST 2007
There is a package available at
http://www.omegahat.org/Prerelease/RSource_0.1-1.tar.gz
that has an extended source() that maintains a list of directories
in which to search for files and a stack of the files currently
being source()d so that one can determine what is currently going on.
It has extra stuff in there for dealing with encrypted files
and also some experiments on I/O using C code which you may not need or
want installed.
D.
Alberto Monteiro wrote:
> Is there a way to know where is the source, so as to make a source call
> inside another source smarter?
>
> As an example:
>
> file1.R is in directory /files/dir1/
>
> file2.R is in directory /files/dir1/dir2/
>
> In file1.R, there is this line:
>
> source("dir2/file2.R")
>
> So, if I setwd to /files/dir1/, and then I call source("file1.R"),
> it will run correctly. However, if I setwd to /files, then
> call source("dir1/file1.R"), it will give an error when
> trying to source file2.R
>
> Alberto Monteiro
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
More information about the R-help
mailing list