make_pipe: Create a pipe operator.

Description Usage Arguments Author(s) See Also Examples

View source: R/pipe.R

Description

This function is used to create magrittr like pipe operators.

Usage

1
2
3
4
5
6
7
make_pipe(propagate, keep_also = NULL, try = FALSE)

lhs %@>% rhs

lhs %<@>% rhs

lhs %try>% rhs

Arguments

propagate

character. See the eponymous argument in shield.

keep_also

character. See the eponymous argument in shield.

try

logical. If TRUE and the pipe x > f generates an error, then the pipe x try> f returns x unchanged silently.

lhs

Left-hand side of the pipe.

rhs

Right-hand side of the pipe.

Author(s)

Stefan Milton Bache and Hadley Wickham for the original pipe function in package magrittr; Paul Poncet for the modifications introduced.

See Also

shield in this package.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
library(dplyr)
df <- data.frame(x = sample(10, 5, rep = TRUE),
                 y = sample(10, 5, rep = TRUE)) %>%
  at_mutate(example = "yes",
            package = "dplyr", 
            class = c("my_tbl", "data.frame"))
tribe(df)

# Attributes just created are lost when the object 
# passes through dplyr verbs
tribe(df %>% mutate(z = 3))

# With the pipe '%@>%', most attributes are kept
tribe(df %@>% mutate(z = 3))

# One can create a new pipe to adjust attributes propagation settings
"%newpipe>%" <- make_pipe(propagate = "none", keep_also = "example")
tribe(df %newpipe>% mutate(z=3))

paulponcet/tribe documentation built on Nov. 24, 2019, 10:08 p.m.