I wonder if someone could explain how the following R idiom works (it's
used in
glm.fit).
start <- coef
start[fit$pivot] <- coef
coef is a vector of coefficients, set by .Fortran("dqrls", ...).
fit$pivot is a vector of integer indexes (indicating how dqrls permuted
the columns
of x). If coef has n elements, fit$pivot is a permutation of seq(1,5).
start[fit$pivot] is simple enough, but the assignment performs a futher
permuation
that I don't understand. For example
pivot <- c(1,3,4,2,5)
a <- c(100,200,300,400,500)
b <- a
b[pivot] <- a
b
[1] 100 400 200 300 500
I guess there must be a replacement function for [], but I haven't
been able to dig up any documentation on it (and I'm not quite sure
where
to look in the source code). I'd like to understand what R does when a
vector
is assigned to another vector in this way.