Re: [R] I really don't understand functions in R :-)

From: Alberto Monteiro <>
Date: Fri 20 Oct 2006 - 17:01:39 GMT

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
# 8
n <- 2
# 8

Thanks for the enlightnment :-)

Alberto Monteiro mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Sat Oct 21 11:52:11 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 21 Oct 2006 - 03:30:11 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.