R Programming: Combine Function: c()

Figure 1

In R programming, the combine function is used to combine arguments into a vector, and to store them in a variable. Such arguments are all coerced into a common type. Except for the names attribute, all other attributes are removed.

R Interpreter

An R interpreter can be used to practice the combine function. Below, six numeric elements are combined and stored in a new nums variable as a vector.

> nums <- c(3, 6, 9, 12, 15, 18) 
> class(nums)
[1] "numeric"
> print(nums)
[1] 3 6 9 12 15 18

The class attribute of the new vector is numeric. The print function displays the six numeric elements stored in the new numeric vector (see Figure 1)