R中矩阵的秩 [英] Rank of a matrix in R
本文介绍了R中矩阵的秩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想测试矩阵的秩,有没有人可以为此推荐 R 中的包/函数?
I want to test the rank of a matrix, is there someone who can recommend a package/function in R for this?
推荐答案
你可以试试函数 qr
("qr",因为它执行一个 QR 分解):
You can try the function qr
("qr", because it performs a QR decomposition):
#define a matrix for this example
M <- matrix(data = rnorm(12), ncol = 3)
#run the function qr()
qr(M)$rank
#Alternative: load the Matrix package...
require(Matrix)
#...and run the function rankMatrix()
rankMatrix(M)[1]
这篇关于R中矩阵的秩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文