From berger @end|ng |rom mp||b-ber||n@mpg@de  Wed Sep 11 12:24:35 2019
From: berger @end|ng |rom mp||b-ber||n@mpg@de (Hilmar Berger)
Date: Wed, 11 Sep 2019 12:24:35 +0200
Subject: [Rd] '==' operator: inconsistency in data.frame(...) == NULL
In-Reply-To: <c21fa68d-00da-dcc1-6390-dce52c889748@mpiib-berlin.mpg.de>
References: <9075d086-7945-b759-f311-765d626b7a61@mpiib-berlin.mpg.de>
 <23928.43189.410927.15494@stat.math.ethz.ch>
 <c21fa68d-00da-dcc1-6390-dce52c889748@mpiib-berlin.mpg.de>
Message-ID: <f144303d-0fa6-7827-bca3-2587a43c3484@mpiib-berlin.mpg.de>

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: berger at mpiib-berlin.mpg.de
Web   : www.mpiib-berlin.mpg.de



[Rd] '==' operator: inconsistency in data.frame(...) == NULL
Hilmar Berger