[Rd] write.csv(..., col.names = FALSE) (PR#13202)

From: Albrecht, Dr. Stefan (AIM SE) <stefan.albrecht_at_apep.com>
Date: Mon, 27 Oct 2008 09:18:32 +0100

Dear Paul,

Thanks for your hint to write.table(). I have already chosen this route.

Note that if row.names = FALSE, col.names gets TRUE and not NA.
> rn <- eval.parent(Call$row.names)
> Call$col.names <- if (is.logical(rn) && !rn)
> TRUE
> else NA

This is in contradiction to your citation and not very helpful, if one wants to append data to a file.

With best regards,
Stefan



Dr. Stefan Albrecht, CFA
Allianz Investment Management SE
AIM-GI-ALM
Königinstr. 28 | 80802 Munich | Germany

Phone: +49.(0)89.3800.18317
Fax: +49.(0)89.3800.818317
EMail: stefan.albrecht_at_allianz.com

Allianz Investment Management SE
Vorsitzender des Verwaltungsrates: Dr. Paul Achleitner Geschäftsführende Direktoren: Dr. Karl-Hermann Lowe, Dr. Bernd Gutting

Sitz der Gesellschaft: München, Deutschland, Registergericht: München HRB 162748 Für Umsatzsteuerzwecke: Ust-ID-Nr.: DE 251 168 597

-----Ursprüngliche Nachricht-----
Von: Paul Roebuck [mailto:plroebuck_at_mdanderson.org] Gesendet: Monday, October 27, 2008 05:59 An: R Development Mailing List
Cc: Albrecht, Dr. Stefan (AIM SE)
Betreff: Re: [Rd] write.csv(..., col.names = FALSE) (PR#13202)

On Fri, 24 Oct 2008 stefan.albrecht_at_allianz.com wrote:

> in write.csv() it is not possible to set both
> row.names = FALSE, col.names = FALSE
> since the col.names = FALSE gets overwritten:
>
> > write.csv
> function (...)
> {
> Call <- match.call(expand.dots = TRUE)
> for (argname in c("col.names", "sep", "dec", "qmethod")) if
> (!is.null(Call[[argname]]))
> warning(gettextf("attempt to set '%s' ignored", argname),
> domain = NA)
> rn <- eval.parent(Call$row.names)
> Call$col.names <- if (is.logical(rn) && !rn)
> TRUE
> else NA
> Call$sep <- ","
> Call$dec <- "."
> Call$qmethod <- "double"
> Call[[1]] <- as.name("write.table")
> eval.parent(Call)
> }
> <environment: namespace:utils>
> >
>
> This is not documented and should be changed, as it is
> an unintended reaction.

?write.csv

> write.csv and write.csv2 provide convenience wrappers
> for writing CSV files. They set sep, dec and qmethod,
> and col.names to NA if row.names=TRUE and TRUE otherwise.

Seems documented to me.

Note that write.csv is just a wrapper for write.table. If you don't like the wrapper, you could always call write.table with its arguments set just as you want.



SIGSIG -- signature too long (core dumped)

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 28 Oct 2008 - 08:11:52 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 28 Oct 2008 - 10:30:43 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive