This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to select rows which has NA in any column in the dataframe in R?

How to select rows which has NA in any column in the dataframe in R?

for example:

enter image description here

dataframe na r

3 answers

you can use the

library(dplyr)

data %>%
 filter_all(any_vars(is.na(.)))

Thanks genius

filter_all and any_vars are deprecated. Instead use filter(df, if_any(everything(), 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,]

Log in to answer this question.