[Rd] Data frame printing buglet when multiple empty column names

Martin Maechler maechler at stat.math.ethz.ch
Tue Mar 1 19:48:30 CET 2016


>>>>> Hadley Wickham <h.wickham at gmail.com>
>>>>>     on Tue, 1 Mar 2016 09:12:00 -0600 writes:

    > This is admittedly minor, and you shouldn't have repeated names in a
    > data frame anyway, but:

    > df <- data.frame(1:3, 1:3, 1:3)

    > # Ok
    > setNames(df, c("x", "y", ""))

    > # Not ok
    > setNames(df, c("x", "", ""))

    > Hadley
    > -- 
    > http://hadley.nz

This has been fixed in R-devel several months ago, but not been
ported to R-patched, the change really being in
format.data.frame(.)  which in R-devel makes use of a quite
smartly improved as.data.frame.list() method.

At the time, I was reluctant to port all these changes to
R-patched, as they were non trivial... but indeed I did like the
result (code, not just this case) quite a bit better.

This is the log entry 
------------------------------------------------------------------------
r69582 | maechler | 2015-10-29 17:12:54 +0100 (Thu, 29 Oct 2015) | 2 lines

PR#16580: data frames with column name "StringsAsFactors" now format and print correctly;
  data.frame() gains argument `fix.empty.names` and as.data.frame.list() gets new `cut.names`, `col.names` and `fix.empty.names`.
------------------------------------------------------------------------


I'm still a bit reluctant to port this to R-patched... but may
could be motivated ...

Martin



More information about the R-devel mailing list