Skip to content
Back to formatted view

Raw Message

Message-ID: <f144303d-0fa6-7827-bca3-2587a43c3484@mpiib-berlin.mpg.de>
Date: 2019-09-11T10:24:35Z
From: Hilmar Berger
Subject: '==' operator: inconsistency in data.frame(...) == NULL
In-Reply-To: <c21fa68d-00da-dcc1-6390-dce52c889748@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