tribe (version 0.1.7)

at_mutate: Manipulate attributes in a dplyr fashion

Description

The function at_mutate adds or changes attributes to obj.

The function at_select selects attributes of obj, and removes the others.

The function at_rename renames attributes of obj.

The function at_slice chooses a specific attribute and returns it.

Usage

at_mutate(obj, ...)

at_mutate_(obj, ..., .dots)

at_select(obj, ...)

at_select_(obj, ..., .dots)

at_rename(obj, ...)

at_rename_(obj, ..., .dots)

at_slice(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

at_slice 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)) %>%
  at_mutate(example="yes",
            package="dplyr")
tribe(df)

at_slice(df, names)
at_slice_(df, "class")
at_slice_(df, ~ package)

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

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

# }

Run the code above in your browser using DataCamp Workspace