After some thought, I wrote a super-simple function called given:
given=function(.,...) { with(.,...) }
This way I do not need to repeat the name data.frame. I also found that it is 14 times faster than filter() . See below:
adf=data.frame(a=1:10,b=11:20) given=function(.,...) { with(.,...) } with(adf,adf[a>5 & b<18,])
Using a Micro Lens
> adf=data.frame(a=1:10,b=11:20) > given=function(.,...) { with(.,...) } > with(adf,adf[a>5 & b<18,])
I noticed that given( ) is actually a little faster than with() , due to the length of the variable name.
The optimal thing about given is that you can do some things without binding: (data.frame (a = 1:10, b = 11: 20), [a> 5 and b <18,])
Chris source share