Omit rows containing specific column of NA

前端 未结 8 1133
感动是毒
感动是毒 2020-11-27 10:39

I want to know how to omit NA values in a data frame, but only in some columns I am interested in.

For example,

DF <- data.frame(x =          


        
相关标签:
8条回答
  • 2020-11-27 11:16

    Use is.na

    DF <- data.frame(x = c(1, 2, 3), y = c(0, 10, NA), z=c(NA, 33, 22))
    DF[!is.na(DF$y),]
    
    0 讨论(0)
  • 2020-11-27 11:18

    Use 'subset'

    DF <- data.frame(x = c(1, 2, 3), y = c(0, 10, NA), z=c(NA, 33, 22))
    subset(DF, !is.na(y))
    
    0 讨论(0)
提交回复
热议问题