Creating Vectors

Harold Nelson

9/12/2021

The c() function.

“c” stands for concatenate, cram together, or collect. It assembles whatever you put in it into a single vector.

Example

x = c(1,3,5)
x
## [1] 1 3 5

Coercion

If the items are of different types, “coercion” will be used to make everything have a type that will accomodate all of the values.

Example

x = c(1,2,"dog")
x
## [1] "1"   "2"   "dog"

Example/Question

What will the following produce?

x = c(1,2,TRUE,FALSE)

Answer

x = c(1,2,TRUE,FALSE)
x
## [1] 1 2 1 0