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

后端 未结 12 1219
我寻月下人不归
我寻月下人不归 2020-12-07 15:28

After importing a file, I always try try to remove spaces from the column names to make referral to column names easier.

Is there a better way to do this other then

12条回答
  •  悲哀的现实
    2020-12-07 16:20

    Just assign to names(ctm2):

      names(ctm2) <- c("itsy", "bitsy", "eeny", "meeny")
    

    or in data-driven way:

      names(ctm2) <- paste("myColumn", 1:ncol(ctm2), sep="")
    

    Another possibility is to edit your source file...

提交回复
热议问题