indexToPosition | R Documentation |
Given a long matrix index convert to row and column positions
indexToPosition(x, nrow = 1)
x |
Position of indices |
nrow |
The number of rows in the matrix |
Using which
on a matrix returns a number that iterates down rows then across columns. This function returns the (row, column) position of that index.
A Matrix with row and column columns and a row for each value of x
Jared P. Lander
indexToPosition(3, 2)
indexToPosition(c(1, 4, 5, 7, 9), 3)
indexToPosition(1:16, 4)
indexToPosition(c(1, 3, 5, 6, 8, 10, 11, 13, 15), 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.