Learn R Programming

yamlet (version 1.2.1)

[.decorated: a <- as_decorated(as.list(setNames(letters[1:3], LETTERS[1:3]))) attr(a$B, 'label') <- 'foo' a <- a[1:3] attributes(a) Subset Decorated

Description

Subsets decorated. Calls promote internally to improve ambiguous conditional attributes where possible.

Usage

# S3 method for decorated
[(x, ..., .promote = getOption("yamlet_promote", TRUE))

Value

decorated (unless dimension is dropped)

Arguments

x

decorated

...

passed to next method

.promote

whether to auto-promote plural attributes

See Also

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

Other decorated: [<-.decorated(), [[.decorated(), [[<-.decorated(), merge.decorated(), names<-.decorated()

Examples

Run this code
library(magrittr)
file <- system.file(package = 'yamlet', 'extdata','phenobarb.csv')
x <- file %>% decorate
x %>% decorations(event, value)

# Subsetting promotes automatically.
x[x$event == 'dose',] %>% decorations(event, value)
x[x$event == 'conc',] %>% decorations(event, value)

# Dimension may be dropped
x[1,1]

# Conventional subsetting
a <- as_decorated(as.list(setNames(letters[1:3], LETTERS[1:3])))
attr(a$B, 'label') <- 'foo'
a <- a[1:3]
attributes(a)

Run the code above in your browser using DataLab