## create data: n > p
set.seed(1234)
n <- 12
p <- 7
X <- matrix(rnorm(n * p), n, p)
## get the full QR decomposition with pivot
qr_res <- fastQR::qr_fast(X = X,
tol = sqrt(.Machine$double.eps),
pivot = TRUE)
## complete the reduced Q matrix
Q <- fastQR::qr_Q_full(qr = qr_res$qr,
tau = qr_res$qraux)
## check the Q matrix (orthogonality)
max(abs(crossprod(Q)-diag(1, n)))
Run the code above in your browser using DataLab