Displaying 1 result from an estimated 1 matches for "trickin".
Did you mean:
tricking
2012 Jun 12
4
How to index a matrix with different row-number for each column?
here's my question: suppose I have a matrix:
mt<-matrix(1:12,ncol=6)
now I have a vector
vt<-c(1,2,2,2,1,2)
which means I want to get:
the 1st row for column1;
the 2nd row for column2;
the 2nd row for column3;
the 2nd row for column4;
...
that what I want is this vector:
1,4,6,8,9,12
Does anyone know how to do this fast?
I know I can use for-loop to travel all columns,but