How to fix spaces in column names of a data.frame (remove spaces, inject dots)?

There exists more elegant and general solution for that purpose:

tidy.name.vector <- make.names(name.vector, unique=TRUE)

make.names() makes syntactically valid names out of character vectors. A syntactically valid name consists of letters, numbers and the dot or underline characters and starts with a letter or the dot not followed by a number.

Additionally, flag unique=TRUE allows you to avoid possible dublicates in new column names.

As code to implement

d<-read_delim(urltxt,delim='\t',)
names(d)<-make.names(names(d),unique = TRUE)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)