[R] Proper way to write data frame with column and row names

Daren Tan daren76 at hotmail.com
Fri Oct 31 02:35:14 CET 2008


I need to write a data frame along with its column and row names to a text file. However, the first row in the text file is always short of one element. I have tried setting different parameters to write.table but that didn't help.

> m
   A B
C 1 2
D 3 4

Using write.table(m, "table.xls", sep="\t", col.names=T, row.names=T) gives

A B
C 1 2
D 3 4



More information about the R-help mailing list