[R] Don't understand write.csv default: Why is column name for column of row names blank?
Earl F. Glynn
efg at stowers-institute.org
Thu Nov 1 00:04:13 CET 2007
I've always been frustrated that R never puts a label on the column name for
a column of row names. This is usually the "key" in a database table, and
it sure would be nice to carry a "key" name along with the data instead of
the field being blank. So, why is it a good idea for it to be blank?
?write.csv says this:
CSV files
By default there is no column name for a column of row names. If
col.names = NA and row.names = TRUE
a blank column name is added, which is the convention used for CSV files
to be read by spreadsheets.
This last sentence doesn't make any sense to me: "the convention used for
CSV files to be read by spreadsheets". Spreadsheets don't care whether this
column is blank or has useful information. R may have a convention to leave
the column name for a column of row names blank (I don't understand why),
but most other applications do not.
I seem to spend a lot of time trying to get this blank field "fixed" since
it's just not right to have a database "key" be blank. I often must
manually edit the .csv file written by R since that's easier than the kludge
to put the column names in a new column one so they can have a column name
too, and then suppress the row names in the write.csv.
What am I missing? Is there an easy way to fill this blank field with a
useful name for a database key when using write.csv defaults?
Thanks for any insight on this.
efg
Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research
More information about the R-help
mailing list