Mutators that Work with Pipes

Mutators to set attributes of variables, that work well in a pipe (much like stats::setNames()).

Project Status: Active - The project has reached a stable, usable state and is being actively developed. Build Status Build status

Mutators to set attributes of variables, that work well in a pipe (much like stats::setNames).


To install the development version, you first need the devtools package.


Then you can install the setter package using



set_* functions change an attribute, then return their first input, allowing you to chain them together. For example, to turn a vector into a matrix, you could do

m <- 1:12 %>%
  set_dim(3:4) %>%
  set_dimnames(list(letters[1:3], LETTERS[1:4])) 
##   A B C  D
## a 1 4 7 10
## b 2 5 8 11
## c 3 6 9 12

To copy attributes from one variable to another, use a copy_* function. %>%
  copy_dim(x) %>%
##   A     B     C     D    
## a "Jan" "Apr" "Jul" "Oct"
## b "Feb" "May" "Aug" "Nov"
## c "Mar" "Jun" "Sep" "Dec"

set_* and copy_* functions are available for the following attributes: names, colnames, rownames, dimnames, class, dim, length.

There are also set_attributes and copy_attributes for setting/copying arbitrary attributes. Here's the previous example thrice more. copy_all_attributes and copy_most_attributes provide a shortcut for copying all the outputs, the latter using base::mostattributes<- to take special care with dim, names and dimnames. %>%
  copy_attributes(x, c("dim", "dimnames")) %>%
  copy_all_attributes(x) %>%
  copy_most_attributes(x) # special care with dim, names, dimnames


0.0-1 First content! set_* and copy_* fns.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.0-1 by Richard Cotton, 3 years ago

Report a bug at

Browse source code at

Authors: Richard Cotton [aut, cre]

Documentation:   PDF Manual  

Unlimited license

Depends on assertive.base

Suggests magrittr, testthat

See at CRAN