View source: R/utils_data.table.R
| dt_set_cleanfactorlevels | R Documentation |
Finds all factors in a data.table and cleans factor levels to include only underscore symbols
dt_set_cleanfactorlevels(x, prefix_digits = NA)
x |
data.table: Input data.table. Will be modified in-place. |
prefix_digits |
Character: If not NA, add this prefix to all factor levels that are numbers |
Nothing, modifies x in-place.
EDG
library(data.table)
x <- as.data.table(iris)
levels(x[["Species"]]) <- c("setosa:iris", "versicolor$iris", "virginica iris")
levels(x[["Species"]])
dt_set_cleanfactorlevels(x)
levels(x[["Species"]])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.