From maechler at stat.math.ethz.ch  Wed Aug  9 10:45:56 2017
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Wed, 9 Aug 2017 10:45:56 +0200
Subject: [Rd] arithmetic with zero-column data.frames
In-Reply-To: <CAF8bMcbJdWbfxHrk9hYaPn+O9pzeMByBfMAePoTPcDPS0wQH3Q@mail.gmail.com>
References: <CAF8bMcbJdWbfxHrk9hYaPn+O9pzeMByBfMAePoTPcDPS0wQH3Q@mail.gmail.com>
Message-ID: <22922.52164.655834.544619@stat.math.ethz.ch>

>>>>> William Dunlap via R-devel <r-devel at r-project.org>
>>>>>     on Tue, 8 Aug 2017 11:59:45 -0700 writes:

    > Should arithmetic operations work on zero-column data.frames (returning a
    > zero-column data.frame with the same number of rows as the data.frame
    > argument(s))?   Currently we get:

    >> 1 + data.frame(row.names=c("A","B"))
    > Error in data.frame(value, row.names = rn, check.names = FALSE, check.rows
    > = FALSE) :
    > row names supplied are of the wrong length
    >> data.frame(row.names=c("A","B")) * 2
    > Error in data.frame(value, row.names = rn, check.names = FALSE, check.rows
    > = FALSE) :
    > row names supplied are of the wrong length
    >> data.frame(row.names=c("A","B")) / data.frame(row.names=c("A","B"))
    > Error in data.frame(value, row.names = rn, check.names = FALSE, check.rows
    > = FALSE) :
    > row names supplied are of the wrong length

    > Bill Dunlap
    > TIBCO Software
    > wdunlap tibco.com

Thank you, Bill.

Yes, indeed, as we have the   Ops.data.frame  and
Math.data.frame group methods  (about which I have not always
been so happy,  but they are inheritance from S),
and as the Math methods work too,  we should get this boundary
case working as well for the Ops.

Martin Maechler
ETH Zurich and R Core



[Rd] arithmetic with zero-column data.frames
Martin Maechler