If all elements of you list are of the same length, maybe you should be using a data.frame. However, Assuming that you want to remove elements within each list element that correspond to the position where ll$c == "one"
, you could use the following lapply
.
lapply(ll, "[", ll$c != "one")
$a
[1] 2 3 4 5
$b
[1] 20 30 40 50
$c
[1] "two" "three" "four" "five"
The second argument indicates the subsetting or extraction function, see ?"[" and the third argument is used to feed the subsetting function with a vector of logicals the same length as ll$c
(and the rest of the list elements).
If there are many list elements, it would be more efficient to calculate the logical vector once initially and then refer to it repeatedly.
keepers <- ll$c != "one"
lapply(ll, "[", keepers)
data
ll <-
structure(list(a = 1:5, b = c(10, 20, 30, 40, 50), c = c("one",
"two", "three", "four", "five")), .Names = c("a", "b", "c"))