Hi David,
This was useful, thanks.
The example was just that, there are no "a"s, "b",s etc I was
just trying to show what I was trying to do.
Using m[v,]
where m was the matrix in my example and v the vector of
index values works great as you suggested Thanks.
R is quite a powerful language
Since you do not offer reproducible code, I must guess that you were
thinking of this as a matrix with 6 instances of "a" across the top
row. See if this helps:
> mtx<-matrix( rep(letters[1:4], 6), nrow=4)
> mtx
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] "a" "a" "a" "a" "a" "a"
[2,] "b" "b
Hello
I have a matrix of size rows x cols.
I also have a vector of size rows.
The vector contains index values that corresponds to rows in the matrix.
I would like to re-arrange/sort the contents of the matrix according
to the entries in the vector. Can this be done efficiently in R and
possib
3 matches
Mail list logo