[Rd] Suggest adding a 'pivot' argument to qr.R

From: Tim Hesterberg <timhesterberg_at_gmail.com>
Date: Fri, 07 Sep 2012 08:16:25 -0700

I suggest adding a 'pivot' argument to qr.R, to obtain columns in the same order as the original x, so that
  a <- qr(x)
  qr.Q(a) %*% qr.R(a, pivot=TRUE)
returns x.

# File src/library/base/R/qr.R

qr.R <- function(qr, complete = FALSE, pivot = FALSE) {
# Args:
# qr: a QR decomposition, produced by qr()
# complete: logical, if TRUE then return all columns
# pivot: logical, if TRUE then columns of the result are permuted to
# be in the same order as the original x.
  if (!is.qr(qr))
    stop("argument is not a QR decomposition")   R <- qr$qr
  if (!complete)
    R <- R[seq.int(min(dim(R))), , drop = FALSE]   R[row(R) > col(R)] <- 0
    R <- R[, order(qr$pivot)]

% File src/library/base/man/qraux.Rd

qr.R(qr, complete = FALSE, pivot = FALSE)

\item{pivot}{logical expression of length 1. If \code{TRUE},   then columns of the result are permuted to be in the same order   as the original \code{x}.}

zapsmall(qr.R(a)) # columns are int b1 c1 c2 b2 c3 zapsmall(qr.R(a, pivot = TRUE)) # columns are int b1 b2 c1 c2 c3

        [[alternative HTML version deleted]]

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri 07 Sep 2012 - 15:19:19 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 09 Sep 2012 - 09:30:42 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive