Is it possible, in the expr
expression of the with()
function, to access the data
argument directly? Here's what I mean conceptually:
> print(df)
result qid f1 f2 f3
1 -1 1 0.0000 0.1253 0.0000
2 -1 1 0.0098 0.0000 0.0000
3 1 1 0.0000 0.0000 0.1941
4 -1 2 0.0000 0.2863 0.0948
5 1 2 0.0000 0.0000 0.0000
6 1 2 0.0000 0.7282 0.9087
> with(df, subset(.data, select=f1:f3)) # Doesn't work
Of course the above example is kind of silly, but it would be handy for things like this:
with(subset(df, f2>0), foo(qid, vars=subset(.data, select=f1:f3)))
I tried to poke around with environment()
and parent.frame()
etc., but didn't come up with anything that worked.
Maybe this is really a question about eval()
, since that's how with.default()
is implemented.