View source: R/data_manip_utils.R
auto_factorize_columns | R Documentation |
For each column of a data frame, if it is a character vector with at least one non-unique value, convert that column to a factor. Character columns with no repeated values (e.g. sample IDs) will not be modified.
auto_factorize_columns(df)
df |
The data frame to operate on. |
df
, possibly with some character columns replaced by
factors
# Initially, both columns are character vectors x <- data.frame(sample = letters, group = LETTERS[1:2], stringsAsFactors = FALSE) sapply(x, class) # This converts group, but not sample, into a factor x2 <- auto_factorize_columns(x) sapply(x2, class)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.