sapply 编写函数,识别含缺失值的列 na.test <- function(df){ i <- 1:ncol(df) df[i[ sapply(i, function(x){sum(is.na(df[x])) > 0}) ]] %>% colnames()}