12.8 What about types?

Only OO objects have a “class” attribute, but every object–whether base or OO–has class

12.8.1 Vectors

typeof(NULL)
#> [1] "NULL"
typeof(c("a", "b", "c"))
#> [1] "character"
typeof(1L)
#> [1] "integer"
typeof(1i)
#> [1] "complex"

12.8.2 Functions

# "normal" function
my_fun <- function(x) { x + 1 }
typeof(my_fun)
#> [1] "closure"
# internal function
typeof(`[`)
#> [1] "special"
# primitive function
typeof(sum)    
#> [1] "builtin"

12.8.3 Environments

typeof(globalenv())
#> [1] "environment"

12.8.4 S4

mle_obj <- stats4::mle(function(x = 1) (x - 2) ^ 2)
typeof(mle_obj)
#> [1] "S4"

12.8.5 Language components

typeof(quote(a))
#> [1] "symbol"
typeof(quote(a + 1))
#> [1] "language"
typeof(formals(my_fun))
#> [1] "pairlist"

12.8.6 Concept Map

Base types in R
Base types in R
Sankey graph code

The graph above was made with SankeyMATIC

// toggle "Show Values"
// set Default Flow Colors from "each flow's Source"

base\ntypes [8] vectors
base\ntypes [3] functions
base\ntypes [1] environments
base\ntypes [1] S4 OOP
base\ntypes [3] language\ncomponents
base\ntypes [6] C components

vectors [1] NULL
vectors [1] logical
vectors [1] integer
vectors [1] double
vectors [1] complex
vectors [1] character
vectors [1] list
vectors [1] raw

functions [1] closure
functions [1] special
functions [1] builtin

environments [1] environment

S4 OOP [1] S4

language\ncomponents [1] symbol
language\ncomponents [1] language
language\ncomponents [1] pairlist

C components [1] externalptr
C components [1] weakref
C components [1] bytecode
C components [1] promise
C components [1] ...
C components [1] any