Bug 15951 - when including row names, write.csv and write.table write inconsistent column name lines.
Summary: when including row names, write.csv and write.table write inconsistent column...
Status: NEW
Alias: None
Product: R
Classification: Unclassified
Component: I/O (show other bugs)
Version: R 3.1.1
Hardware: Other Other
: P5 trivial
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2014-08-26 18:47 UTC by Matthew Plourde
Modified: 2014-08-26 18:47 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Plourde 2014-08-26 18:47:43 UTC
When including row names, `write.csv` writes the column name line prefixed with a comma to indicate that row names are present. However, `write.table` with `sep=','` does not output this initial comma. I'd guess that most folks would expect these two calls to produce the same output. The behavior of `write.csv` seems the most appropriate. 

**Example**

   sample.data <- data.frame(a=1:5, b=letters[1:5])
   temp1 <- tempfile()
   write.csv(sample.data, temp1, quote=FALSE)
   readChar(temp1, file.info(temp1)$size)
   # note the first character is a comma

   write.table(sample.data, temp1, sep=',', quote=FALSE)
   readChar(temp1, file.info(temp1)$size)
   # note that the initial comma from the previous example isn't present

   unlink(temp1)