Alter a function as a parameter before evaluating it?

Posted by Shane on Stack Overflow See other posts from Stack Overflow or by Shane
Published on 2010-04-06T20:39:35Z Indexed on 2010/04/06 20:43 UTC
Read the original article Hit count: 185

Filed under:
|

Is there any way, given a function passed as a parameter, to alter its input parameter string before evaluating it?

Here's pseudo-code for what I'm hoping to achieve:

test.func <- function(a, b) {
    # here I want to alter the b expression before evaluating it:
    b(..., val1=a)
}

Given the function call passed to b, I want to add in a as another parameter without needing to always specify ... in the b call. So the output from this test.func call should be:

test.func(a="a", b=paste(1, 2))
"1"  "2"  "a"

© Stack Overflow or respective owner

Related posts about r

    Related posts about lazy-evaluation