Description Usage Arguments Value See Also Examples

`linearInd`

performs the reverse conversion of
`base::arrayInd`

, that is, it converts so-called
*array indices* (i.e. n-uplets) into *linear indices*.

1 |

`aind` |
Typically a numeric matrix like one returned by
For convenience, Note that no bounds checking is performed, that is, values in the j-th
column of |

`dim` |
An integer vector containing the dimensions of the underlying array. Note that |

An integer vector with one element per row in `aind`

if
`aind`

is a matrix.

A single integer if `aind`

is a vector.

`arrayInd`

in the base package for the reverse
conversion.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ```
dim <- 4:2
linearInd(c(4, 3, 1), dim)
linearInd(c(4, 3, 2), dim)
aind <- rbind(c(1, 1, 1),
c(2, 1, 1),
c(3, 1, 1),
c(4, 1, 1),
c(1, 2, 1),
c(1, 1, 2),
c(4, 3, 2))
linearInd(aind, dim)
## With a matrix of dimensions:
dims <- rbind(c(4L, 3L),
c(5L, 3L),
c(6L, 3L))
aind <- rbind(c(1, 2),
c(1, 2),
c(1, 2))
linearInd(aind, dims)
## Sanity checks:
dim <- c(33:30, 45L, 30L)
stopifnot(linearInd(rep(1, 6), dim) == 1)
stopifnot(linearInd(dim, dim) == prod(dim))
stopifnot(identical(linearInd(arrayInd(1:120, 6:4), 6:4), 1:120))
stopifnot(identical(linearInd(arrayInd(840:1, 4:7), 4:7), 840:1))
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.