atahk / pscl

Political Science Computational Laboratory
65 stars 14 forks source link

Fixed CRAN check error on R-Devel #8

Closed davidaarmstrong closed 4 years ago

davidaarmstrong commented 4 years ago

The pscl package was failing R CMD check on R-devel (particularly on linux systems) because of a new policy for classes and as such is about to be archived. Apparently, R will now assign some built-in classes to objects independent of those assigned by the function/user. As such, class(x) generally returns a vector of at least length 2, so any (in)equality, like class(x) == "x" triggers an error. I changed all if(class(x)=="x") statements to if("x %in% class(x)) and all if(class(x)!="x") to if(!("x" %in% class(x))). After doing so, the package checked clean on R-devel (Debian 9.5).

atahk commented 4 years ago

Thanks for this! I think it's preferable to use inherits(obj, "classname") (or is.data.frame(obj) for data.frames) instead of "classname" %in% class(obj), so I've checked in a new commit that fixes these issues that way. Will push to CRAN shortly.