[Rd] write.csv suggestion

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Jun 29 22:16:01 CEST 2005


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:

> Hello all,
> I had some trouble recently with write.csv because I couldn't change one
> of the default options. A quick view of the code showed that the
> function was not defined in the most optimal way.
>
> Currently,
> write.csv <- function (..., col.names = NA, sep = ",", qmethod =
> "double")
> 	write.table(..., col.names = NA, sep = ",", qmethod = "double")
>
> Thus, the options passed along to write.csv are ignored by the function
> (unless in the ...).
>
> Perhaps a better way to define the function is as such (similar to
> read.csv):
>
> write.csv <- function (..., col.names = NA, sep = ",", qmethod =
> "double")
> 	write.table(..., col.names = col.names, sep = sep, qmethod =
> qmethod)
>
> The same also applies to write.csv2
>
> Best,
> Robert
>
>
>> version
>         _
> platform i386-pc-mingw32
> arch     i386
> os       mingw32
> system   i386, mingw32
> status
> major    2
> minor    1.1
> year     2005
> month    06
> day      20
> language R
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list