An R Introduction to Statistics


A vector is a sequence of data elements of the same basic type. Members in a vector are officially called components. Nevertheless, we will just call them members in this site.

Here is a vector containing three numeric values 2, 3 and 5.

> c(2, 3, 5) 
[1] 2 3 5

And here is a vector of logical values.


A vector can contain character strings.

> c("aa", "bb", "cc", "dd", "ee") 
[1] "aa" "bb" "cc" "dd" "ee"

Incidentally, the number of members in a vector is given by the length function.

> length(c("aa", "bb", "cc", "dd", "ee")) 
[1] 5