Reorders the elements of a matrix row by row according to a corresponding
index matrix. Each row of the index matrix specifies the new column order
for the corresponding row of the input matrix.
Usage
reord_M_R(M, idxG)
Value
A reordered numeric matrix with the same number of rows as `M` and
columns equal to the maximum index in `idxG`.
Arguments
M
A numeric matrix to be reordered.
idxG
An integer matrix of the same number of rows as `M`, where
each row contains column indices indicating the new ordering for that row.
Details
This function performs a scatter-like reordering: for each row `i`, the
values of `M[i, ]` are placed in the positions specified by `idxG[i, ]`.
It is particularly useful for spatial or neighborhood-based rearrangements
where each observation has its own local indexing of neighbors.