Новичок в R, хотел бы удалить ненужную часть из имен столбцов в моем фрейме данных
df <- data.frame(column.0.1 = c(1,2,3,4,5),
column.0.2 = c(1,2,3,4,5),
column.0.3 = c(1,2,3,4,5))
#i have tried
colnames(df) <- sub('\\.[^.]+$', '', colnames(df))
colnames(df)
[1] "column.0" "column.0" "column.0"
#Instead, I want to remove the useless 0 in the middle of the column names so the result would be
[1] "column.1" "column.2" "column.3"
Большое спасибо!