dt_set_cleanfactorlevels: Clean factor levels of data.table _*in-place*_

View source: R/utils_data.table.R

dt_set_cleanfactorlevelsR Documentation

Clean factor levels of data.table in-place

Description

Finds all factors in a data.table and cleans factor levels to include only underscore symbols

Usage

dt_set_cleanfactorlevels(x, prefix_digits = NA)

Arguments

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

Value

Nothing, modifies x in-place.

Author(s)

EDG

Examples

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"]])

rtemis documentation built on Oct. 20, 2026, 1:06 a.m.