[Rd] arithmetic with zero-column data.frames

Martin Maechler maechler at stat.math.ethz.ch
Wed Aug 9 10:45:56 CEST 2017


>>>>> 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



More information about the R-devel mailing list