Determine the number of rows with NAs

前端 未结 5 790
清酒与你
清酒与你 2021-01-22 14:57

I have a data frame as follows:

     col1   col2    col3
 1    23    17      NA
 2    55    NA      NA
 3    24    12      13
 4    34    23      12
5条回答
  •  無奈伤痛
    2021-01-22 15:45

    test <- read.table(textConnection("     col1   col2    col3
    1    23    17      NA
    2    55    NA      NA
    3    24    12      13
    4    34    23      12"))
    
    > table(test$col2,useNA="ifany")
    
      12   17   23  
       1    1    1    1 
    > table(test$col3,useNA="ifany")
    
      12   13  
       1    1    2 
    

提交回复
热议问题