From fabian.scheipl at stat.uni-muenchen.de  Fri Nov 21 17:00:03 2008
From: fabian.scheipl at stat.uni-muenchen.de (fabian.scheipl at stat.uni-muenchen.de)
Date: Fri, 21 Nov 2008 17:00:03 +0100 (CET)
Subject: [Rd] Wishlist: fix error in documentation for body<- (PR#13318)
Message-ID: <20081121160003.8DFAC2834154@mail.pubhealth.ku.dk>

Full_Name: Fabian Scheipl
Version: 2.8.0
OS: Windows, Linux
Submission from: (NULL) (138.246.7.150)


It seems to me that the documentation for body<- is wrong.
The help file for  

body(fun, envir = environment(fun)) <- value

says that:

value can be an expression or a list of R expressions.

This produces errors however:

################################

> f <- function(x){}
> body(f) <- list(expression(res <- x^2),expression(return(x)))
Fehler in as.function.default(c(formals(fun), value), envir) : 
  ung?ltiges formales Argument f?r "function"

################################


The only way to assign multiple statements to a function body
that I could get to work is to put all the statements into a single expression,
(separated by ';' and in curly brackets):

################################

body(f) <- expression({res <- x^2; return(x)})

################################

I think the words 'or a list of R expressions.' should be removed.



[Rd] Wishlist: fix error in documentation for body<- (PR#13318)
fabian.scheipl at stat.uni-muenchen.de