[R] paired samples, matching rows, merge()

Wu Gong wg2f at mtmail.mtsu.edu
Fri Aug 20 14:17:35 CEST 2010


Hi Cecília,

Assuming that you want to pair two samples as more as possible, let's
relabel the k1 indices. The x$k1 c(1,1,2,3,3,5) could be relabeled as
c(1.01,1.02,2.01,3.01,3.02,5.01), so as y$k1. 

x$k1 <- x$k1+sequence(rle(x$k1)$lengths)/100
y$k1 <- y$k1+sequence(rle(y$k1)$lengths)/100
merge(x,y,by="k1")

Regards,

Wu

-----
A R learner.
-- 
View this message in context: http://r.789695.n4.nabble.com/paired-samples-matching-rows-merge-tp2332352p2332402.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list