Dear all, 

I have a problem with the "subset()" function. I spent all day yesterday 
with a collegue to solve it and we did not find a satisfying solution (even 
in the archived mails), so I ask for your help. 
Let's say (for a simple example) a matrix mat: 

R> mat
cola colb colc
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9

My goal is to select the lines of the matrix on the basis of the values of 
more than one column (let's say colb and colc). 
For example I want to select all the lines of the matrix for which values in 
colb and colc are more than 4. 

I tried several ways that did not work: 

R> mat2 <- subset(mat, ("colb">4 & "colc">4))
R> mat2
[1] 1 2 3 4 5 6 7 8 9

it is a vector, not a matrix. 

> mat2 <- subset(mat, mat[,2:3]>4)
> mat2
[1] 2 3 4 5 6 8 9

tha same: it is a vector; so I tried: 

> mat2 <- as.matrix(subset(mat, mat[,("colb">4 & "colc">4)]))
> mat2
[,1]
[1,] 1
[2,] 2
[3,] 3
[4,] 4
[5,] 5
[6,] 6
[7,] 7
[8,] 8
[9,] 9

not good :(

Did someone have an idea of how to select the only the lines 2 and 3 of mat 
by a selection on "colb" and "colc" >4 ? 

Thanks a lot, 

Florence. 

Version 2.0.1 (2004-11-15)
(Linux Debian).

	[[alternative HTML version deleted]]


