Apply ranks from one matrix to another
Posted: Mon May 17, 2021 4:54 am
Hi there,
I'm wondering if there's a quick way to sort the elements of a one matrix according to another?
I currently have two matrices, one containing rates of change for a class of variable (rows = date of observation, columns = variable) and the other containing the weights that apply to each of those variables. I'd like to re-order the columns of this second matrix according to the rank of each variable in the first for each month.
I think @rapplyranks will get me there if I loop through each row, extracting, sorting and @matplace-ing. But I was hoping there might be a shortcut.
Thanks very much.
I'm wondering if there's a quick way to sort the elements of a one matrix according to another?
I currently have two matrices, one containing rates of change for a class of variable (rows = date of observation, columns = variable) and the other containing the weights that apply to each of those variables. I'd like to re-order the columns of this second matrix according to the rank of each variable in the first for each month.
I think @rapplyranks will get me there if I loop through each row, extracting, sorting and @matplace-ing. But I was hoping there might be a shortcut.
Thanks very much.