Skip to content
Prev 257792 / 398502 Next

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:

            
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