2  Introduction

As a statistician and data scientist, the objects I interact with most often in R are data frames and regression models. Actually R’s numbers and vectors are “objects” of a sort, but not in the sense that they need an object system. You can see the difference here:

# you can check whether something is an object with is.object()
is.object( c("a", "b", "c") )
[1] FALSE
is.object( 13 )
[1] FALSE
is.object( data.frame() )
[1] TRUE
# to be an object means to have a class:
attr( c("a", "b", "c"), "class")
NULL
attr( 13, "class")
NULL
attr( data.frame(), "class")
[1] "data.frame"

Objects are the nouns of a computer language. They provide two main functions: encapsulation and polymorphism.