[R] How write the same number of elements in the first line as the rest of the file with write.table()?

Peng Yu pengyu.ut at gmail.com
Thu Sep 17 21:23:29 CEST 2009


Hi,

The first line has less elements than the rest of
'rownames_colnames.write.table.xls'. I am wondering if there is a way
to print an additional '\t' at the beginning of the first line.

$ Rscript write.table.R
> x=matrix(1:20,nc=2)
> rownames(x)=letters[1:10]
> colnames(x)=letters[1:2]
> write.table(x,"rownames_colnames.write.table.xls",sep='\t')
>
$ cat rownames_colnames.write.table.xls
"a"	"b"
"a"	1	11
"b"	2	12
"c"	3	13
"d"	4	14
"e"	5	15
"f"	6	16
"g"	7	17
"h"	8	18
"i"	9	19
"j"	10	20

Regards,
Peng




More information about the R-help mailing list