I have been looking at mapply documentation but I cannot find an example close enough to help me get started.
I have lists foo and bar:
set.seed(123)
f <- data.frame(y=1:10,x=sample(LETTERS,10))
foo <- list(f,f)
b <- data.frame(x=c("J","U","A"))
ba <- data.frame(x=c("J","W"))
bar <- list(b,ba)
I can subset f with b using:
result <- f[f$x %in% b$x ,]
I want to do this subset but for the whole lists foo and bar i.e. subset foo[[1]] by foo[[1]]["x"] on bar[[1]] and foo[[2]] by foo[[2]]["x"] on bar[[2]] etc…
the result would be:
>foo
[[1]]
y x
3 3 J
4 4 U
6 6 A
[[2]]
y x
3 3 J
5 5 W
Like so…?