Learn R Programming

container (version 1.0.0)

discard_at: Discard Elements at Indices

Description

Search and remove values at given indices, which can be numeric or character or both. Invalid indices are ignored.

Usage

discard_at(.x, ...)

ref_discard_at(.x, ...)

# S3 method for Container discard_at(.x, ...)

# S3 method for Container ref_discard_at(.x, ...)

# S3 method for dict.table discard_at(.x, ...)

# S3 method for dict.table ref_discard_at(.x, ...)

Arguments

.x

any R object.

...

indices at which values are to be discarded.

Value

For Container, an object of class Container (or one of the respective derived classes).

For dict.table, an object of class dict.table.

Examples

Run this code
# NOT RUN {
co = container(a = 1, b = 2, 3)
discard_at(co, "a", "b")         # [3]
discard_at(co, 1:2)              # [3]
discard_at(co, "a", 3)           # [b = 2]
discard_at(co, "x")              # ignored

dit = as.dict.table(head(sleep))
discard_at(dit, "ID")
discard_at(dit, "ID", 1)
discard_at(dit, "foo")  # ignored
# }

Run the code above in your browser using DataLab