[R] column names in write.table

Foehl, Matthias Matthias.Foehl at drkw.com
Wed Aug 21 16:48:07 CEST 2002


Dear all,

I want to place titles above columns of data while calling write.table to
create a csv.-file, like

write.table( fc, file="fs.csv", append=F, sep=",",
row.names=T,col.names=c("Index","Rate","Demand","Supply"))


When setting "row.names=T", no column title for the index column is
generated. The R Help says

"Normally there is no column name for a column of row names. If col.names=NA
a blank column name is added. This can be used to write CSV files for input
to spreadsheets. "


But in this case, I want to have the titles as shown above.

For now, I did a

write.table( fs ,file="fs.csv", append=F, sep=",", row.names=T,
col.names=c("Index\",\"Rate","Demand","Supply"))

to artifially generate the title. Wouldn't it be more elegant to provide
this feature by default when row.names=T is set?


Cheers, Matthias


If you have received this e-mail in error or wish to read our e-mail disclaimer 
statement and monitoring policy, please refer to http://www.drkw.com/disc/email/ 
or contact the sender

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list