How about this? PC[na.omit(match(P1[,1],PC[,1])),]
HTH, DYH -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of My Coyne Sent: February 13, 2008 2:07 PM To: [EMAIL PROTECTED] Subject: [R] How to handle Which on two matrices that do not have samenumber of rows R-newbie question I have 2 matrices (a) P1 has only one column of 32K rows (b) PC has 2 column {P, C} of 3200 rows Every values in P1 matches with a value in PC[,p] (column p). I would like to use Which to search for all value in P1 that matchex PC[,p] and get the PC[,c]. However because P1 and PC does not have the same number of rows, I got lots of 'NA'. Thanks for your help. Example.. P1 <- {'p001', 'p001', 'p002', 'p010'..} PC <- { c('p001','class a'), c('p002', 'class b'),.. , c('p010', 'class 10')} Result <- {c('p001', 'class a'), c('p001', 'class a'), c ('p002', 'class b'), c('p010', 'class 10')...} My D. Coyne [[alternative HTML version deleted]] ______________________________________________ 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. ______________________________________________ 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.