Re: [Rd] On read.csv and write.csv

2021-07-09 Thread peter dalgaard
?read.csv does actually have row.names: a vector of row names. This can be a vector giving the actual row names, or a single number giving the column of the table which contains the row names, or character string giving the name of the table column containing the row

Re: [Rd] On read.csv and write.csv

2021-07-05 Thread Stephen Ellison
> From: Simon Urbanek > By default there is no column name for a column of row names. > spreadsheets. Note that such CSV files can be read in R by > >read.csv(file = "", row.names = 1) AHA!! Many thanks. I see this clue is in ?write.table, though; I was looking for help on

Re: [Rd] On read.csv and write.csv

2021-07-01 Thread Simon Urbanek
Just for completeness, all this is well documented: 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. Note

Re: [Rd] On read.csv and write.csv

2021-07-01 Thread John Fox
Dear Gabriel, On 2021-07-01 6:29 p.m., Gabriel Becker wrote: On Thu, Jul 1, 2021 at 1:46 PM Stephen Ellison wrote: Please run the reproducible example provided. When you do, you will see that write.csv writes an unnecessary empty header field ("") over the row names column. This makes the nu

Re: [Rd] On read.csv and write.csv

2021-07-01 Thread Gabriel Becker
On Thu, Jul 1, 2021 at 1:46 PM Stephen Ellison wrote: > > Please run the reproducible example provided. > When you do, you will see that write.csv writes an unnecessary empty > header field ("") over the row names column. This makes the number of > header fields equal to the number of columns _in

Re: [Rd] On read.csv and write.csv

2021-07-01 Thread Stephen Ellison
> the "unhelpful" column are the row names. They are considered an > important part of a data frame and therefore the default (row.names = > TRUE) is to not lose them (as there is no way back once you do). If you don't > want to preserve the row names you can simply set row.names=FALSE. Please run

Re: [Rd] On read.csv and write.csv

2021-07-01 Thread Taras Zakharko
Stephen, I am sure one can find a lot of small issues and inconsistencies with R and it’s standard library. It has to support a lot of legacy cruft and the design process — especially in the early days — focused on getting things done rather than delivering a standard library of immaculate qua

Re: [Rd] On read.csv and write.csv

2021-06-30 Thread Simon Urbanek
Stephen, the "unhelpful" column are the row names. They are considered an important part of a data frame and therefore the default (row.names = TRUE) is to not lose them (as there is no way back once you do). If you don't want to preserve the row names you can simply set row.names=FALSE. Che

Re: [Rd] On read.csv and write.csv

2021-06-30 Thread Gabriel Becker
Hi Stephen, Personally, I don't have super strong feelings about this, but https://datatracker.ietf.org/doc/html/rfc4180#section-2 does say that the optional header line should have the same number of fields as the data records, so in as much as that is the "CSV specification", R's read.csv behavi