indexToPosition

Share:

Description

Given a long matrix index convert to row and column positions

Usage

1

Arguments

x

Position of indices

nrow

The number of rows in the matrix

Details

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.

Value

A Matrix with row and column columns and a row for each value of x

Author(s)

Jared P. Lander

Examples

1
2
3
4
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)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.