Hello,

Let's say we have the following function:

foo <- function(x)

{


    line1 <- x


    line2 <- 0


    line3 <- line1 + line2


    return(line3)

}

 And that we want to change the second line to be:

    line2 <- 2

 How would you do that?

The two ways I know of are either to use

fix(foo)

 And change the function.

Or to just write the function again.

Is there another way?

*What I would like* is for some way to represent the function as a vector of
strings (well, characters), then change one of it's values, and then turn it
into a function again.

The reason I am asking is that I just published a post online where I used a
function to which I did a minor tweak (so to improve it's output for my
particular case).
This tweaking was just adding one line of code, to a function who's length
is 187 lines of code. So instead of repasting all the function on my blog, I
decided to just explain how to edit it.  But I would rather have a simple
code that edited the function for the reader.


Thanks,
Tal

----------------Contact
Details:-------------------------------------------------------
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
----------------------------------------------------------------------------------------------

        [[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.

Reply via email to