epi_clean_count_classes: Get a count of column types from a data frame

View source: R/epi_clean_count_classes.R

epi_clean_count_classesR Documentation

Get a count of column types from a data frame

Description

Count by column type in a data frame. Uses dplyr and purrr, useful when handling large data frames (hundreds of columns and thousands of observations for example).

Usage

epi_clean_count_classes(df = NULL)

Arguments

df

data frame object with columns to count

Value

Returns a table with the counts of column types contained in the data frame.

Note

Note that columns with more than one class will be counted each time (such as POSIX dates), hence ncol() and epi_clean_count_classes() may not match

Author(s)

Antonio Berlanga-Taylor <\url{https://github.com/AntonioJBT/episcout}>

See Also

epi_clean_cond_numeric, epi_clean_class_to_factor, epi_clean_cond_date.

Examples


## Not run: 
set.seed(12345)
n <- 20
df <- data.frame(
  var_id = rep(1:(n / 2), each = 2),
var_to_rep = rep(c('Pre', 'Post'), n / 2),
  x = rnorm(n),
  y = rbinom(n, 1, 0.50),
  z = rpois(n, 2)
)
df$date_col <- seq(as.Date("2018/1/1"), by = "year", length.out = 5)
epi_clean_count_classes(df)

## End(Not run)


AntonioJBT/episcout documentation built on Dec. 1, 2024, 4:07 a.m.