extrobe
2/14/2017 - 5:18 PM

Rename Columns to R-Friendly Names

Rename Columns to R-Friendly Names

# This line of code converts the column names into R-Friendly names (eg, remove spaces)

# Create a dummy matrix
lstNames <- c("Col A","Col B")
df<-matrix(1:8, ncol = 2)
colnames(df)<-lstNames

# Use make.names to convert the existing names to r-friendly names
colnames(df)<-make.names(colnames(df))

# If using a Tibble, perhaps just use names rather colnames - not sure if it makes a difference
names(df)<-make.names(names(df))