I'm fairly new to R and I'm trying to parse data from a PDF into a data table. I've been able to parse the text into a list, but I'm having a hard time trying to filter data from the list.
As an example, consider the sample list below:
l_vectors <- list( c("K", "10", "20"),
c("1", "30", "40"),
c("a", "b", "c"),
c("x", "y", "z"))
Let's say I'd like to filter this list so it only includes the vectors starting with "K" or "1"
I can use map_lgl to find get a logical vector indicating which list items are a match
map_lgl(l_vectors, function(x) x[1] == "K" | x[1] == "1" )
[1] TRUE TRUE FALSE FALSE
From hear I'm not quite sure the best direction. I'm guessing that I'd want to use this logical vector in combination with pluck, but can't seem to figure it out. Any help would be appreciated!
Cheers, Jonathon