R Language Classes Vectors


Example

The most simple data structure available in R is a vector. You can make vectors of numeric values, logical values, and character strings using the c() function. For example:

c(1, 2, 3)
## [1] 1 2 3
c(TRUE, TRUE, FALSE)
## [1]  TRUE  TRUE FALSE
c("a", "b", "c")
## [1] "a" "b" "c"

You can also join to vectors using the c() function.

x <- c(1, 2, 5)
y <- c(3, 4, 6)
z <- c(x, y)
z
## [1] 1 2 5 3 4 6

A more elaborate treatment of how to create vectors can be found in the "Creating vectors" topic