Re: [R] select from matrix

2011-08-08 Thread Joshua Wiley
Hi, ## Better way to make your matrix A - rbind(c(16,10,2,4,8,7), c(16,10,12,14,8,7), c(16,10,13,15,19,17), c(16,9,13,15,9,7)) ## Create logical matrices for conditions 1 2 B1 - rowSums(A[, 2:4] 10) 0 B2 - rowSums(A[, 5:6] 10) 0 ## initialize X at the catch all X - rep(3L, nrow(A)) ##

[R] select from matrix

2011-08-07 Thread gallon li
Suppose I have a matrix like A=matrix(0,4,6) A[1,]=c(16,10,2,4,8,7) A[2,]=c(16,10,12,14,8,7) A[3,]=c(16,10,13,15,19,17) A[4,]=c(16,9,13,15,9,7) A [,1] [,2] [,3] [,4] [,5] [,6] [1,] 16 102487 [2,] 16 10 12 1487 [3,] 16 10 13 151917 [4,]