Created
December 30, 2014 19:03
-
-
Save aousabdo/20977bc773043c1836e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # start clean | |
| rm(list=ls()) | |
| # load libraries | |
| library(data.table) | |
| DT <- data.table(A = rnorm(10), B = rnorm(10)) | |
| # this gives lots of warnings, there seems to be a better way of doing this | |
| names(DT) <- tolower(names(DT)) | |
| # same with this line | |
| names(DT) <- gsub(" ", ".", names(DT)) |
Author
The error message says that it's better to use setnames() instead of names<-. This was meant for older versions of R which copied the entire data.frame/data.table to just replace names. Improvements were made in Rv3.1+. But still the idiomatic way would be to use setnames().
HTH
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updating data.table to dev version 1.9.5 fixes the problem.