Last answered:

03 Dec 2021

Posted on:

03 Dec 2021

0

Shortcut for assigning column names

Suppose you want to assign column names for a data frame you just built but there are a large number of columns (eg - 100). If I want to name the columns 1 to 100, is there a shortcut method of doing this? Maybe by
using the sequence function?

1 answers ( 0 marked as helpful)
Posted on:

03 Dec 2021

0

If you want to give your columns a name that's a number (like you say, col1 = "1", col2 = "2", col3 ="3", etc), you can easily do that with the names() function.

names(df) <- c(1:100)

Submit an answer