[R] removing particular row from matrix
Petr Savicky
savicky at cs.cas.cz
Tue Feb 21 18:46:25 CET 2012
On Tue, Feb 21, 2012 at 07:52:20AM -0800, uday wrote:
> I have some data set which has some values -999.000 & I would like to remove
> whole row of this kind of values.
>
> e.g
> a<-matrix(c(1,2,3,4,4,5,6,6,-999.99,5,9,-999.00),nrow=4)
> a<-
> [,1] [,2] [,3]
> [1,] 1 4 -999.99
> [2,] 2 5 5.00
> [3,] 3 6 9.00
> [4,] 4 6 -999.00
>
> expected answer
>
> [,1] [,2] [,3]
> [1,] 2 5 5.00
> [2,] 3 6 9.00
>
> I am new in R & I got stuck with this step.
Hi.
Try this
a[rowSums(a == -999 | a == -999.99) == 0, ]
[,1] [,2] [,3]
[1,] 2 5 5
[2,] 3 6 9
Hope this helps.
Petr Savicky.
More information about the R-help
mailing list