While reading the dataset use the check.names = FALSE
in read.csv/read.table
to prevent the checks of column names
dat <- read.csv("file.csv", check.names = FALSE)
check.names = TRUE
(default option) triggers make.names
and make.unique
that changes the column names if it doesn't conform to standard format, i.e. it would append X
at the beginning if the column names start with numbers...
If we check the source code of read.table
...
if (check.names)
col.names <- make.names(col.names, unique = TRUE)
...
and make.names
calls make.unique
make.names
function (names, unique = FALSE, allow_ = TRUE)
{
names <- as.character(names)
names2 <- .Internal(make.names(names, allow_))
if (unique) {
o <- order(names != names2)
names2[o] <- make.unique(names2[o])
}
names2
}