[R] select rows by criteria

Rui Barradas rui1174 at sapo.pt
Thu Mar 1 17:10:17 CET 2012


Sorry, correction:

The second index matrix is the matrix of elements not in the first,
not another combination, this time 3 out of 10.

Change this in my first post

> 
> inxmat <- with(DF, combn(ID, 3))
> meansDist2 <- apply(inxmat, 2, function(jnx) f(jnx, DF$value, 45))
> (i2 <- which(meansDist2 == min(meansDist2)))
> 

to this

inxmat2 <- with(DF, apply(inxmat, 2, function(x) setdiff(ID, x)))
meansDist2 <- apply(inxmat2, 2, function(jnx) f(jnx, DF$value, 45))
(i2 <- which(meansDist2 == min(meansDist2)))

Rui Barradas



--
View this message in context: http://r.789695.n4.nabble.com/select-rows-by-criteria-tp4434812p4435408.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list