empyrean
2011-Apr-23 02:35 UTC
[R] How to delete an entire row, if a specific colum has the value of "#VALUE!"
I am importing CSV data with thousands of rows, if any row contains an error from excel, the whole program crashes, so i need to delete all rows with the value of #VALUE!, all other values are non-numeric... I've tried a bunch of strategies, but nothing seems to work. Thanks ahead of time guys, Best, Cody -- View this message in context: http://r.789695.n4.nabble.com/How-to-delete-an-entire-row-if-a-specific-colum-has-the-value-of-VALUE-tp3469282p3469282.html Sent from the R help mailing list archive at Nabble.com.
David Winsemius
2011-Apr-23 06:49 UTC
[R] How to delete an entire row, if a specific colum has the value of "#VALUE!"
On Apr 22, 2011, at 10:35 PM, empyrean wrote:> I am importing CSV data with thousands of rows, if any row contains > an error > from excel, the whole program crashes, so i need to delete all rows > with the > value of #VALUE!, all other values are non-numeric... > > I've tried a bunch of strategies, but nothing seems to work.A set of error targets: > lines <- textConnection("a,#NAME?,b + #DIV/0!,b,v + #VALUE!,bb,nn") > dat <- read.table(lines, sep="," , header=FALSE, comment="") > dat V1 V2 V3 1 a #NAME? b 2 #DIV/0! b v 3 #VALUE! bb nn # This will turn all the #VALUE!'s into <NA>'s > is.na(dat) <- dat == "#VALUE!" > dat V1 V2 V3 1 a #NAME? b 2 #DIV/0! b v 3 <NA> bb nn -- David Winsemius, MD West Hartford, CT