keep_at: Keep or discard elements

Description Usage Arguments Value See Also Examples

View source: R/purrr-misc.R

Description

keep_at() keeps only the elements from specific positions or columns, while discard_at() does the opposite. The functions are wrappers around purrr::keep and purrr::discard, respectively.

Usage

1
2
3
keep_at(.x, .at)

discard_at(.x, .at)

Arguments

.x

A list or vector.

.at

Character (column names) or a numeric (positions).

Value

A list or vector.

See Also

purrr::keep

Examples

1
2
3
4
5
6
7
8
x <- c(1, 2, 3)
names(x) <- c("First", "Second", "Last")
keep_at(x, "Second")
# returns 2

x <- c(1, 2, 3)
discard_at(x, 1)
# returns (2, 3)

numeract/Nmisc documentation built on April 22, 2018, 2:11 p.m.