I have the following data frame lets call it df
, with the following observations:
id type company
1 NA NA
2 NA ADM
3 Nort
Using dplyr, you can also use the filter_at
function
library(dplyr)
df_non_na <- df %>% filter_at(vars(type,company),all_vars(!is.na(.)))
all_vars(!is.na(.))
means that all the variables listed need to be not NA.
If you want to keep rows that have at least one value, you could do:
df_non_na <- df %>% filter_at(vars(type,company),any_vars(!is.na(.)))