indAndSub | R Documentation |
ind2sub
is just an alias for arrayInd
.
sub2ind
is the reverse of ind2sub
.
ind2sub(ind, .dim, .dimnames = NULL, useNames = FALSE)
sub2ind(sub, .dim)
ind |
Vector indices. |
.dim |
|
.dimnames |
optional list of character |
useNames |
logical indicating if the value of |
sub |
Array/matrix indices. |
See arrayInd
.
set.seed(12345)
mat <- matrix(round(runif(6, min = 0, max = 10)), nrow = 2, ncol = 3)
ind2sub(4, dim(mat))
sub2ind(c(2, 2), dim(mat))
subs <- as.matrix(expand.grid(1:2,2:3))
sub2ind(subs, dim(mat))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.