removing particular row from matrix
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 <uday_143_4u at hotmail.com> wrote:
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] [,3] [1,] ? ?1 -999.99 ? ?1 [2,] ? ?2 ? ?5.00 ? ?5 [3,] ? ?3 -999.99 ? ?9 [4,] ? ?5 ? ?6.00 ? ?1 and I would like to remove whole row those have value -999.99 , this particular function does not work I got error Error in rowSums(a[, 2] == -999.99) : ?'x' must be an array of at least two dimensions ?it need matrix, so is there any way to deal with this kind of problem. Cheers Uday -- View this message in context: http://r.789695.n4.nabble.com/removing-particular-row-from-matrix-tp4407401p4411348.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.