[ACCEPTED]-R dataframe naming the headers-dataframe

Accepted answer
Score: 12

If you have dataframe that has c columns, then 3 you can make a vector with c number of strings. Then 2 use the names function to set the headings 1 to be the names of the columns.

col_headings <- c('heading1','heading2', ....,'heading_c')
names(your_dataframe) <- col_headings
Score: 3

Look at the "See Also" section of ?data.frame:

 ‘I’, ‘plot.data.frame’, ‘print.data.frame’, ‘row.names’, ‘names’
 (for the column names), ‘[.data.frame’ for subsetting methods,
 ‘Math.data.frame’ etc, about _Group_ methods for ‘data.frame’s;
 ‘read.table’, ‘make.names’.

There 2 you'll find a reference to names. Now you can 1 read ?names to see how to use it. ;-)

More Related questions