문제

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

My expected output:

 NE122  NE244  NE144
-0.33   0.98    1.0

Cheers.

도움이 되었습니까?

해결책

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))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top