Denote each dataframe category as numeric, categorical, or text and return a list of lists labeled 'numeric', 'categorical' and 'text' containing column names that fall into each category. A 'categorical' column is any column of type 'factor', or any column with fewer than max_cat unique values. A 'numeric' column is any column of type 'numeric' that is not considered 'categorical' under the specified criteria.

categorize(df, max_cat = 10)

Arguments

df

a data.frame

max_cat

int, the maximum number of unique values that define a categorical column

Value

list with char vectors named 'numeric' and 'categorical', containing column names of each type

Examples

categorize(data.frame(a = c(1.2, 2.3, 3.4), b = c('a', 'b', 'c')))
#> $numeric #> character(0) #> #> $categorical #> [1] "b" "a" #>