Jim Holtman wrote:
>
> It sounds like you want to use 'local' to create private variables:
>
Ok, so, in a "real world" example, I should do something
like this:

n <- 3 # but here there is some very complex computations
# that give me a value for n
f <- local({
  f.n <- n
  function(x) x^f.n
})
f(2)
# 8
n <- 2
f(2)
# 8

Thanks for the enlightnment :-)

Alberto Monteiro

______________________________________________
[email protected] 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.

Reply via email to