moodymudskipper / tb

IN ~PROGRESS my own take on `[.data.frame`
0 stars 0 forks source link

`.()` to work as in `bquote()` #11

Closed moodymudskipper closed 4 years ago

moodymudskipper commented 5 years ago

bquote() is just like quote() except that it expands the content of .() by evaluating it in the chosen environment (parent by default).

[.tb works the same by expanding the content of .() before evaluating the arguments or labels (lhs of :=).

So we can do things like the following :

expr <- quote(Sepal.Length * Sepal.Width)
nm   <- quote(Sepal.Area)
iris_tb[.(nm) := .(expr)]

This expansion is done by using expand_expr(), built around code from bquote, but not wrapping bquote directly, for efficiency, and to allow the content of .() to be evaluated through the mask.