Skip to content
Prev 257793 / 398502 Next

How to delete an entire row, if a specific colum has the value of "#VALUE!"

On Apr 23, 2011, at 2:49 AM, David Winsemius wrote:

            
If you still want to remove rows rather than use R's missing value  
facilities, here's a way to eliminate the rows in that result with  
"#NAME?", namely to only return the rows that don't have it and then  
to rbind the results:

 > do.call("rbind", apply(dat,1,function(x) if (!"#NAME?" %in% x)  
{x} ) )
      V1        V2   V3
[1,] "#DIV/0!" "b"  "v"
[2,] NA        "bb" "nn"

(You need to learn to read R code from the inside out.)

David Winsemius, MD
West Hartford, CT