tribe (version 0.1.6)

make_pipe: Create a pipe operator.

Description

This function is used to create magrittr like pipe operators.

Usage

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.

See Also

shield in this package.

Examples

Run this code
# NOT RUN {
library(dplyr)
df <- data.frame(x = sample(10, 5, rep = TRUE),
                 y = sample(10, 5, rep = TRUE)) %>%
  define(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))

# }

Run the code above in your browser using DataLab