qr(x, ...) qr.default(x, tol = 1e-7) is.qr(o) as.qr(o)
is.qr returns TRUE if its argument has qr and qraux components, FALSE otherwise.
as.qr returns its argument if is.qr(x) is TRUE, and qr(x) otherwise.
The method used is the Householder successive reflection procedure, adapted from the implementation used by the LINPACK library. The decomposition is performed in double precision arithmetic.
Golub, G. H. and Van Loan, C. F. (1983). Matrix Computations. Johns Hopkins University Press, Baltimore.
Thisted, R. A. (1988). Elements of Statistical Computing. Chapman and Hall, New York
q <- qr(state.x77)# below is a logical but inefficient function to get an explicit Q and R # it is presented to explain the output of qr rather than to be used per se # (the functions qr.Q and qr.R do this efficiently) function(x) { qrl <- qr(x) r <- qrl$qr r[row(r) > col(r)] <- 0 u <- qrl$qr u[row(u) < col(u)] <- 0 u[row(u) == col(u)] <- qrl$qraux q <- diag(nrow(u)) for(j in 1:ncol(u)) { h <- diag(nrow(u)) - outer(u[, j], u[, j])/qrl$qraux[j] q <- q %*% h } list(q,r) }