1

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?

1 Answer 1

3

We can assign the names with paste

names(df1) <- paste0("X", seq_along(df1))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.