Actually, the correct permutation is given by the inverse of qr$pivot:
foo$coefficients[foo$qr$pivot] - foo$coefficients
Here foo is an object returned by lsfit, see below.
-Original Message-
From: Vadim Ogranovich
Sent: Friday, March 13, 2009 5:25 PM
To: 'r-devel@r-project.org'
Dear R-devel,
It seems that lsfit incorrectly reports coefficients when the input matrix 'x'
is rank-deficient, see the example below:
## here values of 'b' and 'c' are incorrectly swapped
x - cbind(a=rnorm(100), b=0, c=rnorm(100)); y - rnorm(100); lsfit(x, y)$coef
Intercept a