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(~ nchar(.x) == 3)
x %>% discard_at(~ nchar(.x) == 3)
Run the code above in your browser using DataLab