Re: [R] removing particular row from matrix

2012-02-23 Thread S Ellison
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of uday > Error in rowSums(a[, 2] == -999.99) : > 'x' must be an array of at least two dimensions Indeed it must - but you have asked for rowSums on a one-dimensinal object (

Re: [R] removing particular row from matrix

2012-02-22 Thread Sarah Goslee
Is this not what you want: a[a[,2] != -999.99,] I didn't see the earlier message so I'm not sure how rowSums was involved. Sarah On Wed, Feb 22, 2012 at 1:50 PM, uday wrote: > Hi Petr, > Thanks for reply > > sorry for late message there was typo error the both values are -999.99 >  a[rowSums(a

Re: [R] removing particular row from matrix

2012-02-22 Thread R. Michael Weylandt
all you need is rowSums(a == -999.99) -- this will check for -999.99 in *any* spot. If you do only want to check a certain column/row, add drop=FALSE to your subscripting. Michael On Wed, Feb 22, 2012 at 1:50 PM, uday wrote: > Hi Petr, > Thanks for reply > > sorry for late message there was typo

Re: [R] removing particular row from matrix

2012-02-22 Thread uday
Hi Petr, Thanks for reply sorry for late message there was typo error the both values are -999.99 a[rowSums(a == -999.99) == 0, ], this solution works only if we have to remove certain value from matrix. but if a<-matrix(c(1,2,3,5,-999.99,5,-999.99,6,1,5,9,1),nrow=4) a [,1][,2]

Re: [R] removing particular row from matrix

2012-02-22 Thread uday
Hi Dan, I am sorry about that it was typo mistake but the both values are -999.99 . your solution works. Thanks Uday -- View this message in context: http://r.789695.n4.nabble.com/removing-particular-row-from-matrix-tp4407401p4409513.html Sent from the R help mailing list archive at Nabble.c

Re: [R] removing particular row from matrix

2012-02-21 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of uday > Sent: Tuesday, February 21, 2012 7:52 AM > To: r-help@r-project.org > Subject: [R] removing particular row from matrix > > I have some data s

Re: [R] removing particular row from matrix

2012-02-21 Thread Petr Savicky
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,]14 -999.99 >

Re: [R] removing particular row from matrix

2012-02-21 Thread Rui Barradas
Hello, Try a<-matrix(c(1,2,3,4,4,5,6,6,-999.99,5,9,-999.00),nrow=4) ix <- apply(a, 1, function(x) sum(trunc(x) != -999) == ncol(a)) a[ix, ] Hope this helps Rui Barradas -- View this message in context: http://r.789695.n4.nabble.com/removing-particular-row-from-matrix-tp4407401p4407490.html

[R] removing particular row from matrix

2012-02-21 Thread uday
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,]14 -999.99 [2,]255.00 [3,]369.00 [4,]46 -999.00 e