[Rd] is(x,"ANY") is FALSE

Russell Almond ru@@e|| @end|ng |rom r@|mond@net
Tue May 2 22:42:47 CEST 2023


I’m somewhat puzzled by the following bit of code on R 4.2.3 (also R 4.2.2)

> df <- data.frame(x=1:3)
> is (df,"ANY")
[1] FALSE

This seem to be false when the first argument is any S3 class, while I would think that “ANY” would be true for S3, S4 and reference classes, as well as primitive types.

This also seems to be a regression, as code that was previously working no longer works.


A little more context on my use.

I’m defining a slot for a reference class using a type union, 
setClass(“MongoDB”,c(“NULL”,”ANY”))

[I should be using setOldClass(“mongo”) here, but I was having trouble promoting the S3 “mongo” class I was getting from the library.]

Then when I try to set the corresopnding slot I’m getting an error, because “mongo” is not of type MongoDB (even through that is a class union which contains “ANY”).  

I can work around the problem by setting the slot to type “ANY”, but then I loose the documentation that the intention is that it should a mongo database connection.

Did I miss something here?  Or is this an unintended consequence of some other change?

Thanks,
  —Russell Almond




	[[alternative HTML version deleted]]



More information about the R-devel mailing list