Re: [R] counts in quantiles in and from a matrix

2011-10-06 Thread Ben qant
Excellent! Thank you! ben On Wed, Oct 5, 2011 at 9:18 PM, Dennis Murphy wrote: > Hi: > > Here's one way: > > m <- matrix(rpois(100, 8), nrow = 5) > f <- function(x) { >q <- quantile(x, c(0.1, 0.9), na.rm = TRUE) >c(sum(x < q[1]), sum(x > q[2])) >} > > t(apply(m, 1, f)) > > HTH, > De

Re: [R] counts in quantiles in and from a matrix

2011-10-05 Thread Dennis Murphy
Hi: Here's one way: m <- matrix(rpois(100, 8), nrow = 5) f <- function(x) { q <- quantile(x, c(0.1, 0.9), na.rm = TRUE) c(sum(x < q[1]), sum(x > q[2])) } t(apply(m, 1, f)) HTH, Dennis On Wed, Oct 5, 2011 at 8:11 PM, Ben qant wrote: > Hello, > > I'm trying to get the count of value

[R] counts in quantiles in and from a matrix

2011-10-05 Thread Ben qant
Hello, I'm trying to get the count of values in each row that are above and below quantile thresholds. Thanks! Example: > x = matrix(1:30,5,6) > x [,1] [,2] [,3] [,4] [,5] [,6] [1,]16 11 16 21 26 [2,]27 12 17 22 27 [3,]38 13 18 23 28 [4,]4