Re: [R] about body<-

2008-11-30 Thread Gabor Grothendieck
Its also possible to build up a string: > f <- function(x) {} > body(f) <- parse(text = "{ x <- x^5; return(x) }") > f function (x) { x <- x^5 return(x) } On Sun, Nov 30, 2008 at 4:15 AM, ronggui <[EMAIL PROTECTED]> wrote: > In body(fun, envir = environment(fun)) <- value, value can be

[R] about body<-

2008-11-30 Thread ronggui
In body(fun, envir = environment(fun)) <- value, value can be an expression or a list of R expressions. But it seems that value must be length-1 list (if it is a list), is it right? > f2 <- function(x) {} > body(f2) <- list(quote(x<- x^5),quote(return(y))) Error in as.function.default(c(formals(