12.7 How can you tell if an object is base or OOP?
12.7.1 Functions
Two functions:
base::is.object(), which yields TRUE/FALSE about whether is OOP object
sloop::otype(), which says what type of object type: "base", "S3", etc.
An few examples:
# Example 1: a base objectis.object(1:10)#> [1] FALSEsloop::otype(1:10)#> [1] "base"# Example 2: an OO objectis.object(mtcars)#> [1] TRUEsloop::otype(mtcars)#> [1] "S3"
12.7.2 sloop
SLanguage Object-Oriented Programming
12.7.3 Class
OO objects have a “class” attribute:
# base object has no classattr(1:10, "class")#> NULL# OO object has one or more classesattr(mtcars, "class")#> [1] "data.frame"