On 11/26/2007 1:46 PM, Alberto Monteiro wrote: > Duncan Murdoch wrote: >> >> R doesn't really have global variables. <<- goes looking in parent >> environments until it finds the target variable, and makes the >> assignment there. If it never finds one, it makes the assignment in >> the "global environment", but the name is misleading: it should >> really be called the "user workspace". >> > Got it. > > So, in this case: > > x <- 1 > > f <- function() { > x <- 2 > g <- function() { > x <<- 3 > } > g() > x > } > > f() > > It's expected that f will return 3, but x would still be 1?
Yes, the one in the user workspace be unaffected. Duncan Murdoch ______________________________________________ R-help@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.