[R] Source inside source

Alberto Monteiro albmont at centroin.com.br
Tue Jul 17 00:11:05 CEST 2007


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



More information about the R-help mailing list