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

Alberto Monteiro albmont at centroin.com.br
Fri Oct 20 18:41:26 CEST 2006


An example:

n <- 3
f <- function(x) x^n
f(2)
# [1] 8
n <- 2
f(2)
# [1] 4
f
# function(x) x^n

Ok, I know this is trivial, because function f is foverer bound 
to the variable n. But how can I _fix_ n when I define _f_, so 
that changing _n_ won't change the function f?

Alberto Monteiro



More information about the R-help mailing list