function to find common rows between more than two data frames in R
- by biohazard
I have 4 data frames, and would like to find the rows whose values in a certain column do not exist in any of the other data frames. I wrote this function:
#function to test presence of $Name in 3 other datasets
common <- function(a, b, c, d) {
is.B <- is.numeric(a$Name %in% b$Name) == 1
is.C <- is.numeric(a$Name %in% c$Name) == 1
is.D <- is.numeric(a$Name %in% d$Name) == 1
t <- as.numeric(is.B & is.C & is.D)
t
}
However, the output is always t = 0. This means that it tells me that there are no unique rows in any data sets, even though the datas frames have very different numbers of rows. Since there are no duplicate rows in any of the data frames, I should be getting t = 1 for at least some rows in the biggest dataset. Can someone figure out what I got wrong?