Sorry, I can't reproduce the example below even on the same machine.
However, the following example produces the same error as NULL values in
prior examples:
> setClass("FOOCLASS",
+ representation("list")
+ )
> ma = new("FOOCLASS", list(M=matrix(rnorm(300), 30,10)))
> isS4(ma)
[1] TRUE
> data.frame(a=1:3) == ma
Error in matrix(unlist(value, recursive = FALSE, use.names = FALSE),
nrow = nr, :
length of 'dimnames' [2] not equal to array extent
Best,
Hilmar
On 11/09/2019 12:24, Hilmar Berger wrote:
Another example where a data.frame is compared to (here non-null,
non-empty) non-atomic values in Ops.data.frame, resulting in an error
message:
setClass("FOOCLASS2",
slots = c(M="matrix")
)
ma = new("FOOCLASS2", M=matrix(rnorm(300), 30,10))
> isS4(ma)
[1] TRUE
> ma == data.frame(a=1:3)
Error in eval(f) : dims [product 1] do not match the length of object [3]
As for the NULL/logical(0) cases I would suggest to explicitly test
for invalid conditions in Ops.data.frame and generate a comprehensible
message (e.g. "comparison is possible only for atomic and list types")
if appropriate.
Best regards,
Hilmar
On 11/09/2019 11:55, Hilmar Berger wrote:
In the data.frame()==NULL cases I have the impression that the fact
that both sides are non-atomic is not properly detected and therefore
R tries to go on with the == method for data.frames.
From a cursory check in Ops.data.frame() and some debugging I have
the impression that the case of the second argument being non-atomic
or empty is not handled at all and the function progresses until the
end, where it fails in the last step on an empty value:
matrix(unlist(value, recursive = FALSE, use.names = FALSE),
nrow = nr, dimnames = list(rn, cn))
--
Dr. Hilmar Berger, MD
Max Planck Institute for Infection Biology
Charitéplatz 1
D-10117 Berlin
GERMANY
Phone: + 49 30 28460 430
Fax: + 49 30 28460 401
E-Mail: ber...@mpiib-berlin.mpg.de
Web : www.mpiib-berlin.mpg.de
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel