promote.list: Promote a List

View source: R/singularity.R

promote.listR Documentation

Promote a List

Description

Promotes attributes of list-like objects. For the plural attributes of each element, any singularity is promoted to the sole attribute. Reserved attributes are untouched. Methods filter.decorated and [.decorated automatically attempt to promote attributes for all elements.

Usage

## S3 method for class 'list'
promote(
  x,
  ...,
  .reserved = getOption("yamlet_promote_reserved", c("class", "levels", "labels",
    "names"))
)

Arguments

x

list, or list-like

...

indicated elements

.reserved

attributes to leave untouched

Value

same class as x

See Also

filter.decorated [.decorated

Other promote: [.decorated(), filter.decorated(), promote.data.frame(), promote(), singularity()

Other interface: canonical.decorated(), classified.data.frame(), decorate.character(), decorate.data.frame(), desolve.decorated(), ggplot.decorated(), io_csv.character(), io_csv.data.frame(), io_res.character(), io_res.decorated(), io_table.character(), io_table.data.frame(), io_yamlet.character(), io_yamlet.data.frame(), is_parseable.default(), mimic.default(), modify.default(), read_yamlet(), resolve.decorated(), scripted.default(), selected.default(), write_yamlet()

Examples

library(magrittr)
file <- system.file(package = 'yamlet', 'extdata','phenobarb.csv')
x <- file %>% decorate

# Note that there are two elements each for value label and value guide.
x %>% decorations(event, value)

# After filtering, only one set is relevant.
# promote() identifies and retains such.
x %>% dplyr:::filter.data.frame(event == 'dose') %>% decorations(value)
x %>% dplyr:::filter.data.frame(event == 'dose') %>% promote %>% decorations(value)

# If for some reason we do a partial promote, value attributes are unaffected.
# Nonsense example:
x %>% dplyr:::filter.data.frame(event == 'dose') %>% promote(event) %>% decorations(value)

# However, the 'decorated' method for filter() calls promote() internally.
x %>% filter(event == 'dose') %>% decorations(value)


bergsmat/yamlet documentation built on Feb. 18, 2024, 5:50 a.m.