I have a dataset that currently looks like this:
ColumnA ColumnB ColumnC
1 100 100 100
2 100 100 100
3 100 100 100
4 200 200 200
5 300 300 300
6 400 400 400
7 400 400 400
8 500 500 500
9 500 500 500
10 600 600 600
11 700 700 700
In the real dataset, there are 100 columns. I would like to rename them X1,X2,X3,X4,X5....X100. For example:
X1 X2 X3
1 100 100 100
2 100 100 100
3 100 100 100
4 200 200 200
5 300 300 300
6 400 400 400
7 400 400 400
8 500 500 500
9 500 500 500
10 600 600 600
11 700 700 700
Is there a way to do this without having to manually change each of the 100 column names?
CodePudding user response:
We can assign the names
with paste
names(df1) <- paste0("X", seq_along(df1))