Message-ID: <21914262.post@talk.nabble.com>
Date: 2009-02-09T14:46:47Z
From: Ian Fiske
Subject: Re turn values < 0 from Matrix
In-Reply-To: <21913440.post@talk.nabble.com>
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.