Hi,

I have 2 dataframes of unequal length, and I would like to match a
factor to them so that both dataframes will have the same number of
rows.

example:
# create the 2 dataframes with unequal length
data1 <- data.frame(letters, 1:26)[-c(5,10,19:21),]
data2 <- data.frame(letters, 1:26)[-c(6,9,15:18),]


data2a <- match(data1[,1], data2[,1])
data2b <- data2[data2a,]

When I match data1 to data2, and combine the data2a vector to the
original data2, I'm still missing some rows. I need to get the 26
rows, and preferably with the first column displaying all the levels.
In data2b the mismatches show up as NA in the whole row.

Thanks.
Kang Min

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to