On 27.07.2014 15:41, super wrote:
Suppose that I had a function as below: f<-function() { return(1) } i want to change the body of f to the form like this: f<-function(){ 1 function() {} } How can i do the task using body(f) or something else solutions?
See ?body: body(f) <- as.call(c(as.name("{"), expression(1, function(){}))) or parts of it by list indexing ("[[") .... Best, Uwe Ligges
[[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org 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.
______________________________________________ R-help@r-project.org 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.