Re: [R] comparing matrices using max or min

2008-11-06 Thread Dimitris Rizopoulos
you just need pmax() or pmin(), e.g., check this: set.seed(123) M1 <- matrix(rnorm(20), 4, 5) M2 <- matrix(rnorm(20), 4, 5) M3 <- matrix(rnorm(20), 4, 5) M1; M2; M3 pmax(M1, M2, M3) pmin(M1, M2, M3) I hope it helps. Best, Dimitris Diogo André Alagador wrote: Dear all, I have 3 matrices w

Re: [R] comparing matrices using max or min

2008-11-06 Thread stephen sefick
#how about this A <- rnorm(10) B <- rnorm(10) C <- rnorm(10) D <- data.frame(A,B,C) apply(D, MARGIN=1, FUN=min) On Thu, Nov 6, 2008 at 10:00 AM, Diogo André Alagador <[EMAIL PROTECTED]> wrote: > Dear all, > > I have 3 matrices with the same dimension, A,B,C and I would like to produce > a matrix

[R] comparing matrices using max or min

2008-11-06 Thread Diogo André Alagador
Dear all, I have 3 matrices with the same dimension, A,B,C and I would like to produce a matrix D where in each position would retrieve the max(or min) value along A,B,C taken from the same position. I guess that apply functions should fit, but for matrices objects I am not getting it. thanks i