# Re: [Rd] Bug in qr.R ? (PR#9655)

From: <ripley_at_stats.ox.ac.uk>
Date: Sat, 05 May 2007 10:09:55 +0200 (CEST)

And the purported bug is what: you failed to say! This looks most like a misreading on your part of the documentation.

The help page says:

complete: logical expression of length 1. Indicates whether an

```           arbitrary  orthogonal completion of the *Q* or *X* matrices
is to be made, or whether the *R* matrix is to be completed
by binding zero-value rows beneath the square upper triangle.

```

You only need to complete R for n < p, as in:

> A <- matrix(1:12, 4)
>
> qr.R(qr(A),complete=TRUE)

[,1] [,2] [,3]

```[1,] -5.477226 -12.780193 -2.008316e+01
[2,]  0.000000  -3.265986 -6.531973e+00
[3,]  0.000000   0.000000  2.641083e-15
[4,]  0.000000   0.000000  0.000000e+00

>  qr.R(qr(A),complete=FALSE)
[,1]       [,2]          [,3]
[1,] -5.477226 -12.780193 -2.008316e+01
```

[2,] 0.000000 -3.265986 -6.531973e+00
[3,] 0.000000 0.000000 2.641083e-15

On Fri, 4 May 2007, Dietrich.Trenkler_at_uni-osnabrueck.de wrote:

>
> using
>
> > A <- structure(c(1, 0, 0, 3, 2, 1, 4, 5, -3, -2, 1, 0), .Dim =
> as.integer(c(3,4)))
>
> I get
>
> > dim(A)
> [1] 3 4
>
> > qr.R(qr(A),complete=TRUE)
> [,1] [,2] [,3] [,4]
> [1,] -1 -3.000000 -4.000000 2.0000000
> [2,] 0 -2.236068 -3.130495 -0.8944272
> [3,] 0 0.000000 -4.919350 -0.4472136
> > qr.R(qr(A),complete=FALSE)
> [,1] [,2] [,3] [,4]
> [1,] -1 -3.000000 -4.000000 2.0000000
> [2,] 0 -2.236068 -3.130495 -0.8944272
> [3,] 0 0.000000 -4.919350 -0.4472136
>
> In ?qr.R I find
>
> /qr.R returns R. The number of rows of R is nrow(X) or ncol(X),
> depending on whether complete is TRUE or FALSE./
>
> As you can see, the number of rows stays the same...

But it says it is one of the two values, and that which depends on 'complete' (but not that different values of 'complete' necessarily give different answers, just that they might). You may have read this as if it said 'respectively', but it does not.

[...]

```--
Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
```
Received on Sat 05 May 2007 - 08:13:41 GMT

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 Sat 05 May 2007 - 13:34:05 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.