R/describe_NA.R

Defines functions describe_NA

Documented in describe_NA

#' Return tidy summary of NAs in dataframe
#'
#' Function to return a dataframe with description of frequency of NAs
#' in target dataframe.
#'
#' @param data Dataframe.
#' @export
#' @examples describe_NA(mice::boys)

#**********************************************************
describe_NA = function(data) {

  count.NA <- colSums(is.na(data))

  prop.NA <- round(colMeans(is.na(data)), 2)

  names(count.NA) <- NULL
  names(prop.NA) <- NULL

  data.frame(variable = names(data),
             count.NA,
             prop.NA)

}
#**********************************************************
wepelham3/sack2 documentation built on Aug. 5, 2023, 5:53 a.m.