Skip to content
Prev 76964 / 398502 Next

how to do something like " subset(mat, ("col1">4 & "col2">4)) "

Some thing like this?

mat <- matrix(1:9,3,3)
mat
mat[apply(mat[,2:3] > 4,1,all),]
# or less cryptically
foo <- mat[,2:3] > 4
bar <- apply(foo,1,all)
mat[bar,]

HTH, Andy

NB: No need to send this kind of message to r-devel
http://www.R-project.org/posting-guide.html