What ways are there to edit a function in R?

Posted by Tal Galili on Stack Overflow See other posts from Stack Overflow or by Tal Galili
Published on 2010-03-16T20:47:50Z Indexed on 2010/03/16 20:51 UTC
Read the original article Hit count: 141

Filed under:
|
|

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?

One way is to use

fix(foo)

And change the function.

Another way is to just write the function again.

Is there another way? (Remember, the task was to change just the second line)

© Stack Overflow or respective owner

Related posts about r

    Related posts about functions