pipeops: Pipe operators to enhance magrittr

Description Usage Arguments Details Examples

Description

These operators all return the same as magrittr's pipe operator but have additional side effects.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
lhs %W>% rhs

lhs %G>% rhs

lhs %S>% rhs

lhs %P>% rhs

lhs %D>% rhs

lhs %V>% rhs

lhs %L>% rhs

lhs %C>% rhs

lhs %strict>% rhs

Arguments

lhs

A value or the magrittr placeholder.

rhs

A function call using the magrittr semantics.

Details

%W>%

silence warnings

%strict>%

fail on warning

%V>%

uses View() on the output

%L>%

logs the relevant call to the console

%P>%

uses print() on the output

%S>%

prints the summary() off the output

%G>%

uses tibble::glimpse on the output

%D>%

debugs the pipe chain at the relevant step

%C>%

clocks the relevant step

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# silence a warning
data.frame(a= c(1,-1)) %W>% transform(a=sqrt(a))

# view stepps of chain in the viewer
iris %V>% head(2) %V>% `[`(4:5)

# log steps in the console
iris %L>% {Sys.sleep(1);head(.,2)} %L>% {Sys.sleep(2);.[4:5]}

# use print, summary or glimpse on output
iris %P>% head(2) %P>% `[`(4:5)
iris %S>% head(2) %S>% `[`(4:5)
iris %G>% head(2) %G>% `[`(4:5)

# debug the chain
iris %>% head(2) %D>% `[`(4:5)

moodymudskipper/mmpipe documentation built on May 17, 2019, 10:39 a.m.