extract: Extract Elements from a Named Object

Description Usage Arguments Details See Also Examples

View source: R/extract.R

Description

Extracts elements from an R object with the names attribute set in a 'lazy' way. The first argument is the object, while the second is a set of names parsed from .... We return the object, including only the elements with names matched from ....

Usage

1

Arguments

x

An R object with a names attribute.

...

an optional number of 'names' to match in dat.

Details

We can be 'lazy' with how we pass names. The names passed to ... are not evaluated directly; rather, their character representation is taken and used for extraction.

See Also

without, extract.re

Examples

1
2
3
4
dat <- data.frame( x = c(1, 2, 3), y = c("a", "b", "c"), z=c(4, 5, 6) )
## all of these return identical output
dat[ names(dat) %in% c("x","z") ]
extract( dat, x, z)

Kmisc documentation built on May 29, 2017, 1:43 p.m.

Search within the Kmisc package
Search all R packages, documentation and source code