demagrittr: Decompile magrittr's syntax to normal R's syntax

Description Usage Arguments Examples

Description

Semantics of %>% is eager evaluation, the example of magrittr is not accurate. x %>% f is not equivalent to f(x) but equals to {tmp <- x; f(tmp)} or {force(x); f(x)}. demagrittr() converts magrittr's syntax to such eager evaluation.

Usage

1
demagrittr(expr, is_NSE = TRUE, mode = c("eager", "lazy", "promise"))

Arguments

expr

expression with magrittr functions such as "%>%"

is_NSE

if TRUE, expr is not evaluated.

mode

choose one of "eager", "lazy", and "promise". Pipe streams are formed along with such mode.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
demagrittr(x %>% f)
demagrittr(x %>% f(y))
demagrittr(x %>% f %>% g %>% h)

demagrittr(x %>% f(y, .))
demagrittr(x %>% f(y, z = .))

demagrittr(x %>% f(y = nrow(.), z = ncol(.)))
demagrittr(x %>% {f(y = nrow(.), z = ncol(.))})

demagrittr(x %>% f %>% g, mode = "eager") # default
demagrittr(x %>% f %>% g, mode = "lazy")
demagrittr(x %>% f %>% g, mode = "promise")

TobCap/demagrittr documentation built on May 9, 2019, 4:50 p.m.