R/count_all.R

Defines functions count_all

Documented in count_all

#' Returns a list of count tables for all variables in a dataframe
#'
#' Returns a list of count tables for all variables in a dataframe. This is useful in EDA for getting an overview of character and factor variables
#' @param data is the data
#' @keywords EDA count
#' @import dplyr
#' @export
#' @examples
#' nycflights13:flights %>% select_if(is.factor) %>% count_all()

count_all <- function(data){
  assertthat::assert_that(is.data.frame(data))
  data %>% purrr::map(~dplyr::count(data.frame(x = .x), x))
}
Kidapt/keda documentation built on Oct. 15, 2019, 9:01 p.m.