keep_at {purrr} | R Documentation |
Keep/discard elements based on their name/position
Description
Keep/discard elements based on their name/position
Usage
keep_at(x, at)
discard_at(x, at)
Arguments
See Also
keep()
/discard()
to keep/discard elements by value.
Examples
x <- c(a = 1, b = 2, cat = 10, dog = 15, elephant = 5, e = 10)
x |> keep_at(letters)
x |> discard_at(letters)
# Can also use a function
x |> keep_at(\(x) nchar(x) == 3)
x |> discard_at(\(x) nchar(x) == 3)
[Package purrr version 1.1.0 Index]