In order to use vector thinking we use a variety of ways to create vectors, matrices and higher dimensional arrays. Here are the main functions for creating vectors with examples:
| concatenation | c(rep(5,3), 1:5, c(2,17)) |
| sequence operator | 1:7 |
| sequence function | seq(-pi, pi, length=200) |
| replication function | rep(1:3, c(5,3,1)) |
| random iids | rnorm(100, mean=100, sd=15) |
| random samples | sample(1:365, size=15, replace=T) |
| input from a file | scan("c:\\mydata") |