Skip to content

Data frame printing buglet when multiple empty column names

3 messages · Hadley Wickham, Martin Maechler

#
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
#
> 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
#
On Tue, Mar 1, 2016 at 12:48 PM, Martin Maechler
<maechler at stat.math.ethz.ch> wrote:
Thanks Martin!
It's not high priority for me - I'm happy knowing that it'll be fixed in R 3.3.0

Hadley