Learn R Programming

matlib (version 0.9.8)

R: Rank of a Matrix

Description

Returns the rank of a matrix X, using the QR decomposition, QR. Included here as a simple function, because rank does something different and it is not obvious what to use for matrix rank.

Usage

R(X)

Value

rank of X

Arguments

X

a matrix

See Also

Examples

Run this code
M <- outer(1:3, 3:1)
M
R(M)

M <- matrix(1:9, 3, 3)
M
R(M)
# why rank=2?
echelon(M)

set.seed(1234)
M <- matrix(sample(1:9), 3, 3)
M
R(M)

Run the code above in your browser using DataLab