Programmatically distinguishing S3 and S4 objects in R

Viewed 283

If given an object x, is there a way to classify whether or not it is S3 or S4 (or "other")? I have looked at is.object() and isS4(), and can identify that something is an object (or not) and that it is an S4 object (or not). However, it doesn't seem to me that S3 objects are the complement of all objects that are not S4 objects.

Therefore, how can these assignments be done programmatically?

Here is an example of something that bugs me, taken from the help for is.object():

a = as.factor(1:3)
is.object(a)  # TRUE
isS4(a) # FALSE

Does that mean that a is an S3 object?

1 Answers
Related