I have list of 10 dataframes and I want to select one row of each datafram by name. The name of the column is name. And I want to select each row in which name=Ready.
I tried some approaches. This works, if I state the exact row number (here 2):
lapply(list, `[` ,c(2),)
But as the row number is different in the dataframes I would apply somehting like name=Ready:
lapply(list, `[` ,c(Ready),)
You can use lapply
as -
lapply(list, function(x) x[x$name == 'Ready', ])
couple of other alternatives which would give the same result
lapply(list, subset, name == 'Ready')
#tidyverse
library(dplyr)
library(purrr)
map(list, ~.x %>% filter(name == 'Ready'))