Port of the R CMD check note "Found if() conditions comparing class() to string"
(checking R code for possible problems, _R_CHECK_CODE_CLASS_IS_STRING_).
As an object may have more than one class, class(x) == "a" gives a condition longer than one (an error since
R 4.2) or misses a subclass; inherits(x, "a") is what is meant.
Readonlyinfo: { certainty:BestEffort; defaultConfig:()=>{checkWhile:true;resolveStrings:true}; description:"Finds `if`/`while` conditions comparing `class(x)` with a string, which fail for objects with several classes. Offers `inherits(x, ...)` as a quick fix."; name:"Class String Comparison"; tags:readonly[CmdCheck,Bug,Robustness,QuickFix]; }
Port of the
R CMD checknote "Found if() conditions comparing class() to string" (checking R code for possible problems,_R_CHECK_CODE_CLASS_IS_STRING_). As an object may have more than one class,class(x) == "a"gives a condition longer than one (an error since R 4.2) or misses a subclass;inherits(x, "a")is what is meant.