May I am missing something, but it seems to me that the easiest way to solve your problem, if you don't want to change 'n', is to define
f <- function(x) x^3 If you want to allow the possibility for 'n' to change, you can include it as an argument of 'f' f <- function(x,n=3) x^n Best, Giovanni > Date: Fri, 20 Oct 2006 14:41:26 -0200 > From: Alberto Monteiro <[EMAIL PROTECTED]> > Sender: [EMAIL PROTECTED] > Precedence: list > > 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 > > ______________________________________________ > [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. > > -- __________________________________________________ [ ] [ Giovanni Petris [EMAIL PROTECTED] ] [ Department of Mathematical Sciences ] [ University of Arkansas - Fayetteville, AR 72701 ] [ Ph: (479) 575-6324, 575-8630 (fax) ] [ http://definetti.uark.edu/~gpetris/ ] [__________________________________________________] ______________________________________________ [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.
