[R] select rows by criteria
syrvn
mentor_ at gmx.net
Thu Mar 1 13:27:45 CET 2012
Hello,
I am stuck with selecting the right rows from a data frame. I think the
problem is rather how to select them
then how to implement the R code.
Consider the following data frame:
df <- data.frame(ID = c(1,2,3,4,5,6,7,8,9,10), value =
c(34,12,23,25,34,42,48,29,30,27))
What I want to achieve is to select 7 rows (values) so that the mean value
of those rows are closest
to the value of 35 and the remaining 3 rows (values) are closest to 45.
However, each value is only
allowed to be sampled once!
Any ideas, how to achieve that?
Cheers
--
View this message in context: http://r.789695.n4.nabble.com/select-rows-by-criteria-tp4434812p4434812.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list