i try this to remove the "return" statement in the body(f):
tmp<-as.character(body(f))
a<-sub("return","#return",tmp)
but i don't know how to transfer the character form back to call form or language form or expression form ? 
Is the method i posted could  be implemented correctly, or Is there other ways to remove the "return" statements from body(f)?










At 2014-07-28 00:25:20, "William Dunlap" <wdunlap@tibco.com> wrote:
>I find bquote() handy for this sort of manipulation.  E.g.,
>> f <- function() { 1 }
>> origBody <- body(f)
>> newBody <- bquote({ .(origBody) ; .(addedStuff) }, list(origBody=origBody, addedStuff=quote(function(){})))
>> body(f) <- newBody
>> f
>function ()
>{
>    {
>        1
>    }
>    function() {
>    }
>}
>> f()
>function ()
>{
>}
><environment: 0x2a38350>
>
>
>Bill Dunlap
>TIBCO Software
>wdunlap tibco.com
>
>
>On Sun, Jul 27, 2014 at 6:41 AM, super <desolator88@163.com> 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?
>>         [[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.

	[[alternative HTML version deleted]]

