## generate sample data
set.seed(1234)
n <- 12
p <- 5
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)
## get the pivot matrix
P <- qr_pivot2perm(qr_res$pivot)
Run the code above in your browser using DataLab