Skip to Content

R Self Organising Subset

I have a matrix with a hundred rows.
Is there a way to obtain a subset of ten rows which are most similar to the first row.

res2 <- matrix(rexp(200, rate=.1), ncol=10, nrow=100)
 
set1 <- subset(res2, res2 >condition1)
set1[with(set1, order(condition)), ]
set2 <- head(set1,10)