Skip to content

write.csv suggestion

2 messages · McGehee, Robert, Brian Ripley

#
I didn't want to use a different separator, I wanted to remove
row.names, as in this example:
= TRUE)
Error in if (col.names) d[[2]] else NULL : 
	missing value where TRUE/FALSE needed

I only mentioned this suggestion because the above syntax seemed
reasonable (and self-documenting), but by making the options
unchangeable, I received an unhelpful error message.

After checking the code, I rewrote the line to this:
FALSE, col.names = TRUE)

This only seemed suboptimal (to me) because one would have to read the
code to know that the col.names = TRUE option was not being passed along
to write.table (as I expected).

Best,
Robert

-----Original Message-----
From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] 
Sent: Wednesday, June 29, 2005 4:16 PM
To: McGehee, Robert
Cc: r-devel at stat.math.ethz.ch
Subject: Re: [Rd] write.csv suggestion


The help page says

      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.  This can be used to write CSV files for input to
      spreadsheets.  'write.csv' and 'write.csv2' provide convenience
      wrappers for doing so.

and they are set up to disallow the options they set to be changed.

If you get the option wrong to read a file, you will know soon enough,
but 
these are to ensure a suitable CSV file gets written (which will not be
so
immediately apparent).

Please define `optimal': doing what it was designed for and is
documented 
to do is according to you not `optimal'.

Why would anyone want to use write.csv to write files with something
other 
than a comma/semicolon as separator, rather than use write.table?
On Wed, 29 Jun 2005, McGehee, Robert wrote:

            
one
function

  
    
#
I've changed this in R-devel so row.names = FALSE is allowed in 
write.csv[2], but changing col.names, dec, sep and qmethod are not 
allowed.  (col.names is set depending on the setting of row.names.)

So far attempts to change col.names, dec, sep and qmethod are silently 
ignored but I may add some warnings.
On Wed, 29 Jun 2005, McGehee, Robert wrote:

            
OK, but the documentation did explicitly say it was a wrapper for 
row.names = TRUE.