create_dummies {framecleaner}R Documentation

create dummies

Description

adapted from the dummy_cols function Added the option to truncate the dummy column names, and to specify dummy cols using tidyselect.

Usage

create_dummies(
  .data,
  ...,
  append_col_name = TRUE,
  max_levels = 10L,
  remove_first_dummy = FALSE,
  remove_most_frequent_dummy = FALSE,
  clean_names = TRUE,
  ignore_na = FALSE,
  split = NULL,
  remove_selected_columns = TRUE
)

Arguments

.data

data frame

...

tidyselect columns. default selection is all character or factor variables

append_col_name

logical, default TRUE. Appends original column name to dummy col name

max_levels

uses fct_lump_n to limit the number of categories. Only the top n levels are preserved, and the rest being lumped into "other". Default is set to 10 levels, to prevent accidental overload. Set value to Inf to use all levels

remove_first_dummy

logical, default FALSE.

remove_most_frequent_dummy

logical, default FALSE

clean_names

logical, default TRUE. apply clean_names

ignore_na

logical, default FALSE

split

NULL

remove_selected_columns

logical, default TRUE

Details

reference the fastDummies package for documentation on the original function.

Value

data frame

Examples


iris %>%
create_dummies(Species, append_col_name = FALSE) %>%
  tibble::as_tibble()



[Package framecleaner version 0.2.1 Index]