From m@echler @ending from @t@t@m@th@ethz@ch  Thu May 24 17:44:40 2018
From: m@echler @ending from @t@t@m@th@ethz@ch (Martin Maechler)
Date: Thu, 24 May 2018 17:44:40 +0200
Subject: [Rd] Bug on qr.coef when qr is created by a zero matrix with
 colnames and all y equals zero
In-Reply-To: <CA42C690-92B8-4F46-AB4A-1A37A06C64CA@contoso.com>
References: <CA42C690-92B8-4F46-AB4A-1A37A06C64CA@contoso.com>
Message-ID: <23302.56808.849660.344554@stat.math.ethz.ch>

>>>>> Kun Ren 
>>>>>     on Sat, 19 May 2018 08:17:37 +0000 writes:

    > Dear maintainers,
    > I'm reporting a bug in qr.coef that mishandles the colnames of matrix. A minimal reproducible example is as follows:

    > x <- cbind(rep(0, 10), rep(0, 10))
    > y <- rep(0, 10)
    > q <- qr.default(x)
    > qr.coef(q, y)
    > [1] NA NA

    > If x has colnames, then qr.coef will end up with an error:

    > x <- cbind(x1 = rep(0, 10), x2 = rep(0, 10))
    > y <- rep(0, 10)
    > q <- qr.default(x)
    > qr.coef(q, y)
    > Error in qr.coef(q, y) : object 'pivotted' not found

    > This happens only when x any y are all zeros. I found this problem when I implement a qr-based wls which stops when all weights are zero and the x matrix has colnames.

    > A brief debug on qr.coef shows that when `nam` is not NULL, no branch of code leads to creating `pivotted` before using it finally.?

Dear Kun,

this is indeed a bug, and I will address it.

Thank you very much for the reprex (:= [repr]oducible [ex]ample)!

Best,
Martin Maechler



[Rd] Bug on qr.coef when qr is created by a zero matrix with colnames and all y equals zero
Martin Maechler