dot_mutate | R Documentation |
Evaluate an arbitrary mutating expression in a magrittr pipe
dot_mutate(x, expr)
x |
The object to assign into. (Typically this argument is
delivered via |
expr |
The expression to be evaluated with |
The value of x
after evaluating expr
.
As usual, x
, the object being passed in, should be
referenced in expr
as .
.
Note that this function uses the lazyeval package rather than its apparent successor, rlang, because rlang doesn't support interpolating expressions on the left-hand-side of an assignment operation: https://github.com/r-lib/rlang/issues/212.
library(magrittr) # Returns the entire list, not just a single element list(a = 1, b = 2, c = 3) %>% dot_mutate(.$d <- 4) %>% dot_mutate({ .$e <- 5; .$f <- 6}) # Compare: list(a = 1, b = 2, c = 3) %>% {.$d <- 4} %>% print
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.