[R] Re turn values < 0 from Matrix
    Ian Fiske 
    ianfiske at gmail.com
       
    Mon Feb  9 15:46:47 CET 2009
    
    
  
If your matrix is called mat, how about
mat[which(mat[,2] > 0), ]
mat[which(mat[,2] < 0), ]
-Ian
mentor_ wrote:
> 
> Hi,
> 
> I have a matrix with negative and positiv values.
> How can I get either the negative or positive values from the matrix?
> 
> Matrix:
>      [,1] [,2]
> [1,]    1   -3
> [2,]    2   -2
> [3,]    3    5
> [4,]    4   -2
> [5,]    5    9
> [6,]    6    8
> [7,]    7   -2
> 
> What I want to have is:
> 
>      [,1] [,2]
> [1,]    1   -3
> [2,]    2   -2
> [3,]    4   -2
> [4,]    7   -2
> 
> and:
> 
>      [,1] [,2]
> [1,]    3    5
> [2,]    5    9
> [3,]    6    8
> 
> 
> Regards
> 
-- 
View this message in context: http://www.nabble.com/Return-values-%3C-0-from-Matrix-tp21913440p21914262.html
Sent from the R help mailing list archive at Nabble.com.
    
    
More information about the R-help
mailing list