Skip to content
Back to formatted view

Raw Message

Message-ID: <55D0A072.2060605@yeah.net>
Date: 2015-08-16T14:38:42Z
From: Jinsong Zhao
Subject: difference between write.csv(...) and write.table(..., sep=", ")

Hi there,

I notice that write.csv is a wrap of write.table. However, I can't get 
the same results using both functions. Here is a reproducible example:

 > x <- matrix(1:6, nrow =2)
 > rownames(x) <- letters[1:2]
 > colnames(x) <- LETTERS[1:3]
 > write.csv(x, "")
"","A","B","C"
"a",1,3,5
"b",2,4,6
 > write.table(x, "", sep = ",")
"A","B","C"
"a",1,3,5
"b",2,4,6

The difference of outputs from both functions is clear.

Is it possible to get the same results of write.csv using write.table?

Any suggestions will be really appreciated. Thanks in advance.

Best,
Jinsong