Search notes:

R function: vector

vec_num <- vector(mode="numeric", length=10)
show(vec_num)
#  [1] 0 0 0 0 0 0 0 0 0 0

is.vector(vec_num)
# [1] TRUE

dim(vec_num)
# NULL
Github repository about-r, path: /functions/vector.R

Scalars

A scalar is a vector with exactly one element.
So, pi and pi[1] yield the same value: 3.141…

Matrices

A matrix is a vector whose dim attribute is set.
vec <- 1:12
dim(vec)
# NULL

dim(vec) <- c(3, 4)
vec
#      [,1] [,2] [,3] [,4]
# [1,]    1    4    7   10
# [2,]    2    5    8   11
# [3,]    3    6    9   12

dim(vec)
# [1] 3 4
Github repository about-r, path: /vector/matrix.R

See also

vectors
Index to (some) R functions

Index