On Fri, 20 Oct 2000, Jorge Luis Ojeda Cabrera wrote:
>
> I 've been working with R since last year and I am quite
"happy" with R
> capabilities. Nevertheless, I need to present my job to other people
> (S-users) and I am facing a problem with R & S compatibility: my
> R-scripts make intensive use of functions local scope, and as far as I
> know(I am a new to S) S does not have this capability.
>
> I use to do things like:
>
> create.f <- function(data)
> {
> f <- function(x) { return( sum(data-x) );}
> return( f )
> }
>
> d <- 1:10
> g <- create.f(d)
> d <- NULL
> g(1)
> [1] 45
>
> Does exist an easy way to solve the problem ?
> May be I've missed some easier implementation in R..?
This sort of R function can be ported to S using the MC() (make
closure) function by Luke Tierney that appears in the FAQ (section 3.3.1).
-thomas
Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._