测试数据如下:
Itun <- data.frame(v1 = c(1,1,2,1,2,1), v2 = c(NA, 1, 2, 1, 2, NA))
Itun[ , colSums(is.na(Itun)) == 0]
output:
[1] 1 1 2 1 2 1
另一种方式:
Itun[ , apply(Itun, 2, function(x) !any(is.na(x)))]
output:
[1] 1 1 2 1 2 1
参考
点这里
测试数据如下:
Itun <- data.frame(v1 = c(1,1,2,1,2,1), v2 = c(NA, 1, 2, 1, 2, NA))
Itun[ , colSums(is.na(Itun)) == 0]
output:
[1] 1 1 2 1 2 1
另一种方式:
Itun[ , apply(Itun, 2, function(x) !any(is.na(x)))]
output:
[1] 1 1 2 1 2 1
参考
点这里