# [R] rank of a matrix

Huntsinger, Reid reid_huntsinger at merck.com
Wed May 4 19:18:23 CEST 2005

```qr() returns an estimate of the rank. However the rank of a matrix isn't
really computable (or useful) in general in finite precision arithmetic. The
Hilbert matrix example (from help(svd)) is a good illustration:

> hilbert <- function(n) { i <- 1:n; 1 / outer(i - 1, i, "+") }
> qr(hilbert(9))\$rank
[1] 7

but it's actually an invertible 9 x 9 matrix.

Rather you can estimate how far a matrix is from having rank <= k for
example. A book on numerical linear algebra would be a good reference.

A common approach to statistical analysis of certain kinds of data deals
with the ranks of the data values, and that's why you got so many hits for
"rank".

Reid Huntsinger

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of mingan
Sent: Wednesday, May 04, 2005 11:54 AM
To: r-help at stat.math.ethz.ch
Subject: [R] rank of a matrix

how do I check the rank of a matrix ?

say

A=  1   0   0
0   1   0

then rank(A)=2

what is this function?

thanks

I did try help.search("rank"), but all the returned help information
seem irrelevant to what I want.

I would like to know how people search for help information like this.

rank(base)              Sample Ranks
SignRank(stats)         Distribution of the Wilcoxon Signed Rank
Statistic
Wilcoxon(stats)         Distribution of the Wilcoxon Rank Sum
Statistic
friedman.test(stats)    Friedman Rank Sum Test
kruskal.test(stats)     Kruskal-Wallis Rank Sum Test
pairwise.wilcox.test(stats)
Pairwise Wilcoxon rank sum tests
wilcox.test(stats)      Wilcoxon Rank Sum and Signed Rank Tests

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help