ind2subs: Convert linear index to matrix subscripts

Description Usage Arguments Value

View source: R/utils.R

Description

Takes a vector of integers (1D linear indexed) and converts them to matrix subscripts in n-dimensional matrix. Modeled after MATLAB's ind2sub()

Usage

1
ind2subs(ind, dims)

Arguments

ind

An integer vector with linear indexes

dims

An n-dimensional integer vector. Each element of this vector indicates the size of the corresponding dimension in the n-dimensional matrixc.

Value

A list of n lists of equal length. Each list corresponds to one of the n dimensions of the matrix. Rows indicate subscripts. Suitable for use with mapping functions.


noah documentation built on Jan. 18, 2021, 5:06 p.m.