bracket {pipebind}R Documentation

Pipe-able aliases

Description

pipebind provides several aliases for unary/binary operators (e.g., +) and replacement functions (e.g., ⁠names<-()⁠) that facilitate using these functions in a ⁠|>⁠ chain.

Some unary/binary operators cannot currently be used with the ⁠|>⁠ pipe, such as +, -, or %*%. These aliases provide a way to use these functions with the ⁠|>⁠ pipe.

Currently implemented aliases are

Extract and replace elements
bracket `[`
double_bracket `[[`
assign_bracket `[<-`
assign_double_bracket `[<-`
dollar `$`
at_sign `@`
Arithmetic operators
add `+`
subtract `-`
multiply `*`
divide `/`
integer_divide `%/%`
mod `%%`
raise_to_power `^`
matrix_multiply `%*%`
Logical comparisons
and `&`
or `|`
not `!`
single_and `&&`
single_or `||`
equals `==`
greater_than `>`
greater_or_equal `>=`
less_than `<`
less_or_equal `<=`
is_in `%in%`
Assign attributes
assign_names `names<-`
assign_colnames `colnames<-`
assign_rownames `rownames<-`
assign_dimnames `dimnames<-`
assign_class `class<-`
assign_attributes `attributes<-`
assign_attr `attr<-`
assign_levels `levels<-`
assign_contrasts `contrasts<-`
assign_units `units<-`
assign_comment `comment<-`
assign_diag `diag<-`
assign_dim `dim<-`
assign_length `length<-`
assign_as_na `is.na<-`

Note

Inspired and some alias names adapted from from magrittr. Reused code Copyright (c) 2023 magrittr authors.

Examples

 mtcars |>
   bracket(, 1:4)

 1:10 |>
   add(5) |>
   matrix(dimnames = list(letters[1:10], "x")) |>
   matrix_multiply(seq(10, 100, by = 10))

data.frame(1:10, letters[1:10]) |>
  assign_names(c("numbers", "letters"))

[Package pipebind version 0.1.2 Index]