# for vectors
misses <- c(NA, NA, NA)
complete <- c(1, 2, 3)
mixture <- c(NA, 1, NA)
all_na(misses)
all_na(complete)
all_na(mixture)
all_complete(misses)
all_complete(complete)
all_complete(mixture)
any_na(misses)
any_na(complete)
any_na(mixture)
# for data frames
all_na(airquality)
# an alias of all_na
all_miss(airquality)
all_complete(airquality)
any_na(airquality)
any_complete(airquality)
# use in identifying columns with all missing/complete
library(dplyr)
# for printing
aq <- as_tibble(airquality)
aq
# select variables with all missing values
aq %>% select(where(all_na))
# there are none!
#' # select columns with any NA values
aq %>% select(where(any_na))
# select only columns with all complete data
aq %>% select(where(all_complete))
# select columns where there are any complete cases (all the data)
aq %>% select(where(any_complete))
Run the code above in your browser using DataLab