November 2016
Beginner to intermediate
959 pages
43h 46m
English
In this recipe, we will dive into R's capability with regard to matrices.

A vector in R is defined using the c() notation as follows:
vec = c(1:10)
A vector is a one-dimensional array. A matrix is a multidimensional array. We can define a matrix in R using the matrix() function. Alternatively, we can also coerce a set of values to be a matrix using the as.matrix() function:
mat = matrix(c(1,2,3,4,5,6,7,8,9,10),nrow = 2, ncol = 5) mat
To generate a transpose of a matrix, we can use the t() function:
t(mat) # transpose a matrix
In R, we can also generate an identity matrix using the diag() function:
d = diag(3) # generate an identity ...
Read now
Unlock full access