tags:

views:

398

answers:

3

Is there a command in R that will allow you to write a CSV file that has the row and column names of a matrix (dimnames(M))? Whenever I output the file, the names are gone.

help(write)

doesn't mention that this is possible to do.

+1  A: 

Use write.table(...,row.names=TRUE,col.names=TRUE,sep=",")

Rob Hyndman
A: 

Note that there is an entire manual dedicated to questions like this, it really does not hurt to look at those once in a while.

Dirk Eddelbuettel
I agree. I always find a new nugget or two when I skim through these. A longer list of required reads can be found here: http://cran.r-project.org/manuals.html
Christopher DuBois
+4  A: 

Use write.csv

hadley