Top Menu

Matrix Algebra

Most of the methods on this website actually describe the programming of matrices. It is built deeply into the R language. This section will simply cover operators and functions specifically suited to linear algebra. Before proceeding you many want to review the sections on Data Types and Operators.

Matrix facilites

In the following examples, A and B are matrices and x and b are a vectors.

Single value decomposition of A.y$d = vector containing the singular values of A
y$u = matrix with columns contain the left singular vectors of Ay$v = matrix with columns contain the right singular vectors of A

QR decomposition of A. y$qr has an upper triangle that contains the decomposition and a lower triangle that contains information on the Q decomposition. y$rank is the rank of A. y$qraux a vector which contains additional information on Q. y$pivot contains information on the pivoting strategy used.

cbind(A,B,...)

Combine matrices(vectors) horizontally. Returns a matrix.

rbind(A,B,...)

Combine matrices(vectors) vertically. Returns a matrix.

rowMeans(A)

Returns vector of row means.

rowSums(A)

Returns vector of row sums.

colMeans(A)

Returns vector of column means.

colSums(A)

Returns vector of column sums.

Matlab Emulation

The matlab package contains wrapper functions and variables used to replicate MATLAB function calls as best possible. This can help porting MATLAB applications and code to R.