I have the following list:
x <- list(1:5, 1:10)
x
#> [[1]]
#> [1] 1 2 3 4 5
#> [[2]]
#> [1] 1 2 3 4 5 6 7 8 9 10
and would like to select only items containing 10.
Desired Result:
How can I do this briefly and on one line using the pipe operator and purrr package?
. the code works but feels a little awkward.
x %>% map_lgl(~contains(.,10L)) %>% subset(x,.)
Is there a better way to use xa pipe operator every time?
source
share