[R] Matching vector order by indicators in a matrix
Jeremy Beaulieu
jeremy.beaulieu at yale.edu
Thu Jun 16 23:52:41 CEST 2011
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 the vector by the number in the following matrix:
$Index.matrix
ALPHA 1 1
BETA 2 2
In other words, the first value in $Rates should go wherever there is a "1" in the $Index.matrix. And the second value should go wherever there is a "2", and so on. I have some pretty hacky solutions, but I wanted to see if there was an easy way to do this that I am completely missing.
Thanks and all the best,
Jeremy
More information about the R-help
mailing list