Entering edit mode
2.1 years ago
Amr
▴
180
How to select rows which has NA in any column in the dataframe in R?
for example:
How to select rows which has NA in any column in the dataframe in R?
for example:
you can use the
library(dplyr)
data %>%
filter_all(any_vars(is.na(.)))
We could negate complete.cases:
data[ !complete.cases(data), ]
No NAs:
data[rowSums(apply(data,1,is.na)) == 0,]
Any NAs:
data[rowSums(apply(data,1,is.na)) > 0,]
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
filter_all
andany_vars
are deprecated. Instead usefilter(df, if_any(everything(), is.na))
.Thanks genius