Skip to contents

Converts all column names to lowercase, replaces any run of non-alphanumeric characters with a single underscore, and strips leading/trailing underscores. Duplicate names are disambiguated with a numeric suffix (same behaviour as janitor::clean_names()).

Usage

.normalise_colnames(dt)

Arguments

dt

A data.table.

Value

The same data.table with normalised column names (modified by reference via data.table::setnames()).

Details

Kept as a standalone helper so it can be tested in isolation and reused anywhere a data.table needs name normalisation without loading janitor.