First, everything in R is treated like as an object. We have seen this with functions. Many of the objects that are created within an R session have attributes associated with them. One common attribute associated with an object is its class.
You can set the class attribute using the class command. One thing to notice is that the class is a vector which allows an object to inherit from multiple classes, and it allows you to specify the order of inheritance for complex classes. You can also use the class command to determine the classes associated with an object.
- > bubba <- c(1,2,3)
- > bubba
- [1] 1 2 3
- >
- > class(bubba)
- [1] "numeric"
- >
- > class(bubba) <- append(class(bubba),"Flamboyancy")
- > class(bubba)
- [1] "numeric" "Flamboyancy"