Question on the idiom: start <- coef; start[fit$pivot] <- coef
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. Thanks, (and thanks for all the other help I've gotten from member of the list lately) ------------------- Barnet Wagman wagman at enteract.com 773-645-8369 1361 N. Hoyne Chicago, IL 60622 -------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._