indexByRow {matrixStats} | R Documentation |
Translates matrix indices by rows into indices by columns.
indexByRow(x, idxs=NULL, ...)
x |
A matrix . |
idxs |
A vector of indices. If NULL , all indices are returned. |
... |
Not use. |
Returns an integer
vector
of indices.
Henrik Bengtsson (http://www.braju.com/R/)
x <- matrix(NA, nrow=5, ncol=4) y <- t(x) idxs <- seq(along=x) # Assign by columns x[idxs] <- idxs print(x) # Assign by rows y[indexByRow(y, idxs)] <- idxs print(y) stopifnot(x == t(y))