tribe (version 0.1.6)

define: Manipulate attributes in a dplyr fashion

Description

The function define (synonym: at_mutate) adds or changes attributes to obj.

The function keep (synonym: at_select) selects attributes of obj, and removes the others.

The function rebrand (synonym: at_rename) renames attributes of obj.

The function take (synonym: at_slice) chooses a specific attribute and returns it.

Usage

define(obj, ...)

at_mutate(obj, ...)

define_(obj, ..., .dots)

at_mutate_(obj, ..., .dots)

keep(obj, ...)

at_select(obj, ...)

keep_(obj, ..., .dots)

at_select_(obj, ..., .dots)

rebrand(obj, ...)

at_rename(obj, ...)

rebrand_(obj, ..., .dots)

at_rename_(obj, ..., .dots)

take(obj, at)

at_slice(obj, at)

take_(obj, at)

at_slice_(obj, at)

Arguments

obj

An object.

...

Comma separated list of unquoted expressions.

.dots

Used to work around non-standard evaluation.

at

Attribute to be obtained.

Value

take returns the attribute chosen. The other functions return obj with possibly modified attributes.

See Also

structure, attributes

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")
tribe(df)

take(df, names)
take_(df, "class")
take_(df, ~ package)

df <- df %>%
  define_(package = ~ NULL,
          example = ~ "no")
tribe(df)

df <- df %>% 
  define_(.dots = list(x =~ 2, y =~ c(3,4)))
tribe(df)

# }

Run the code above in your browser using DataLab