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)
This is a feed of questions about R from StackOverflow.com. Follow the link at the bottom of each question to find answers from StackOverflow.com users.
StackOverflow user contributions are licensed under cc-wiki with attribution required.
inside-R.org is a collection of resources about the open-source R Project for the R Statistics Community. This site is sponsored by Revolution Analytics.
Follow @inside_R on Twitter for updates about this site.
If you have questions or ideas for the site, please send us an email at community@inside-R.org.