indexToPosition: indexToPosition

View source: R/indices.r

indexToPositionR Documentation

indexToPosition

Description

Given a long matrix index convert to row and column positions

Usage

indexToPosition(x, nrow = 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

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)


jaredlander/useful documentation built on Nov. 4, 2023, 10:56 a.m.