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]]
Michael Lawrence (MICHAFLA)
2023-May-02 23:01 UTC
[Rd] [Sender Not Verified] is(x,"ANY") is FALSE
Hi, This does seem to be a bug in is(); I'll take a look. I'm curious about what stopped you from using setOldClass(), since that seems to be the most appropriate solution. Michael On Tue, May 2, 2023 at 2:59?PM Russell Almond <russell at ralmond.net> wrote:> > 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]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel-- Michael Lawrence Senior Principal Scientist, Director of Data Science and Statistical Computing Genentech, A Member of the Roche Group Office +1 (650) 225-7760 michafla at gene.com Join Genentech on LinkedIn | Twitter | Facebook | Instagram | YouTube
Maybe Matching Threads
- no connectivity to some hosts behind tinc for the first few seconds
- Announcing release for MongoDB 2.4 and 2.6 on CentOS Linux 6 x86_64 SCL
- Announcing release for MongoDB 2.4 and 2.6 on CentOS Linux 7 x86_64 SCL
- Unsuccessful with using mongodb with rails
- Mongoid : bson namespace error