I\'m trying to get which objects of a list have an specific value in one of their columns.
In order to explain my case, please run the following simple example:
<
We could loop through the list, check whether there is any element in 'gear' column that is equal to 4, use that to subset the names of the list
names(mt_list)[sapply(mt_list, function(x) any(x$gear == 4))]
#[1] "4" "6"
Or use %in% to create the logical index
names(mt_list)[sapply(mt_list, function(x) 4 %in% x$gear)]
#[1] "4" "6"