[ACCEPTED]-R dataframe naming the headers-dataframe
Accepted answer
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
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. ;-)
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.