Rename columns by pattern in R

前端 未结 1 769
轮回少年
轮回少年 2020-12-06 07:40

I would like to rename all my columns in a dataframe by a specific pattern.

My input:

Log.NE122  Log.NE244  Log.NE144
-0.33       0.98        1.0


        
相关标签:
1条回答
  • 2020-12-06 08:06

    You can use regular expressions to change the colnames() of an object. Here I'm replacing the Log. with nothing:

    colnames(object) <- sub("Log\\.", "", colnames(object))
    
    0 讨论(0)
提交回复
热议问题