Find columns with all missing values

后端 未结 8 461
Happy的楠姐
Happy的楠姐 2020-12-09 08:42

I am writing a function, which needs a check on whether (and which!) column (variable) has all missing values (NA, ). The following is fr

相关标签:
8条回答
  • 2020-12-09 09:07
    sapply(b,function(X) sum(is.na(X))
    

    This will give you the count of na in each column of the dataset and also will give 0 if there is no na present in the column

    0 讨论(0)
  • 2020-12-09 09:10

    dplyr approach to finding the number of NAs for each column:

    df %>% 
      summarise_all((funs(sum(is.na(.))))) 
    
    0 讨论(0)
提交回复
热议问题