Closed AndreMikulec closed 7 years ago
AndreMikulec,
Thanks for your input and examples. The free-subsitution is pretty far away from the intent of let
, but fairly close to the behavior of beval
and ateval
. So I am adding a new function (now available in the development version) with behavior close to what you describe as seval
(now in the development version of wrapr
).
The following all works:
seval( alias=list(SORT_COLUMNS = "cyl, disp"), {
head(dplyr::arrange(mtcars, SORT_COLUMNS ))
})
seval( alias=list(SORT_COLUMNS = "cyl, disp"), {
mtcars %>% dplyr::arrange(SORT_COLUMNS) %>% head
})
mtcars %>% (function(x) {
seval( alias=list(SORT_COLUMNS = "cyl, disp"), {
x %>% dplyr::arrange(SORT_COLUMNS) %>% head
})
})
As far as direct piping forms (such as letp
and a possible sevalp
). I used to have a letp()
in replyr
as replyr
declares dplyr
(and hence magrittr
pipe) as a dependency). But I never liked the solution needed to get around the function wrapping needed in the the 3rd of the above examples. It really looked like it would be a problem to maintain going forward. I just don't have generic solution for the direct piping adapter that will meet certain standards. So I have (unfortunately) much given up on try to safely supply the p
-"ready to pipe" forms, that is being left to user code.
Hopefully that is close to your ask. I know it doesn't completely match- but my intent is to keep let
itself very strict so it is very early to reason about. The more general submitters are beval
, ateval
, and seval
. And finally I have been asked by others to keep wrapr
an R-only dependency free package that can be used both with or without the tidyverse (so it can't declare a dplyr
, magritter
, stringr
, or stringi
dependency).
Thanks.
If the 'methods of' mapping from desired names to names used in the data were liberalized, then this liberalization would be very useful. For for example, a name could map to 'other than a name.'
WORKS
WORKS
Without the hard-coded data.frame mtcars Good enough for piping
WORKS
shortest working way to write
WORKS