#' Matrix rank
#'
#' @param x numeric matrix.
#' @param method method used for computing rank.
#' @param tol the tolerance for detecting linear dependencies in the columns of x.
#'
#' @seealso
#' \code{\link{qr}}, \code{\link{chol}}, \code{\link{svd}}
#'
#' @export
mtxrank <- function(x, method = c("qr", "qr.lapack", "chol", "svd"), tol = 1e-7) {
method <- match.arg(method)
switch(method,
"svd" = sum(svd(x)$d > tol),
"chol" = attr(chol(x, pivot = TRUE, tol = tol), "rank"),
"qr.lapack" = qr(x, LAPACK = TRUE, tol = tol)$rank,
qr(x, tol = tol)$rank
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.