strange behaviour when sourcing inside function
Thanks for your reply! You may be correct, but the documentation of "source" reads as whether the opposite is the case regarding the use of TRUE and FALSE, doesn't it? Your interpretation may be correct (it would be also in line with my inutive interpretation of the combination of the word local and the corresponding boolean values) but if it is, the manual (to me) is misleading. Cheers Jannis
On 22.08.2012 21:25, Noia Raindrops wrote:
Hello,
If argument 'local' is FALSE, 'source' function is evaluating the file in global environment
and object 'a' is not in global environment.
Function's environment is just local. And environment() in a function returns the function's environment.
test <- function () source("test.R", local = FALSE)
# test.R is evaluated in global environment.
test <- function () source("test.R", local = environment())
# environment() returns the envrionment of 'test' function.
test <- function () source("test.R", local = TRUE)
# this is same as above.