Besides the obvious arguments for readability and performance, you should almost never have to test a class of objects with class(foo) == "class" , since you cannot rely on it to give the correct result.
As nrussell commented, an S3 class system supports "inheritance" through tagging objects with more than one class name. As soon as more than one class name appears, this equality check will give nonsense.
Instead, use either:
if (inherits(obj, 'class')) โฆ action โฆ
Or, if you explicitly want to run an exact test, rather than an inheritance test (which should be extremely rare):
if (identical(class(obj), 'class')) โฆ action โฆ
Konrad Rudolph
source share