Skip to content
Prev 247259 / 398503 Next

Unexpected behaviour of write.csv - read.csv

On Thu, 13 Jan 2011, Duncan Murdoch wrote:

            
You need to read it with read.csv("x.csv", row.names=1)

Nothing in the csv format lets R know that the first column is the row 
names (in the format used by read.table, having a header that is one 
column short does).  Now R could guess that a .csv file with an empty 
string for the first column name is meant to be the row names, but 
that would be merely a guess based on one (barely documented for 
spreadsheets) convention.
Or one of the other serialization options such as serialize() and 
.saveRDS().  R's own admin uses .saveRDS() for such purposes.