[R] Matching vector order by indicators in a matrix

2011-06-16 Thread Jeremy Beaulieu
Hi all~ I have a bit of stupid question. And I promise, I have struggled through this and it sort of pains me to post this question... I have the following vector which is are the estimated parameter values output from optim. $Rates [1] 0.006280048 0.330934659 I want to match the order in

Re: [R] Matching vector order by indicators in a matrix

2011-06-16 Thread Marc Schwartz
On Jun 16, 2011, at 4:52 PM, Jeremy Beaulieu wrote: Hi all~ I have a bit of stupid question. And I promise, I have struggled through this and it sort of pains me to post this question... I have the following vector which is are the estimated parameter values output from optim.

Re: [R] Matching vector order by indicators in a matrix

2011-06-16 Thread Bert Gunter
Folks: This is sufficiently tricky that a word of explanation might be helpful to reveal the magic. Rates - c(0.006280048, 0.330934659) Index.Matrix - matrix(c(1, 2, 1, 2), 2, 2) Rates [1] 0.006280048 0.330934659 Index.Matrix     [,1] [,2] [1,]    1    1 [2,]    2    2 Just index