This function maps indices from an input vector to corresponding sequences of
grouped indices. Each element from the input specifies a group to be mapped
from the sequence, determined by the grouping size n.
Arguments
- indices
[
integer()]
An index vector, where each element specifies a group to be mapped from the sequence.- n
[
integer]
The size of each group of consecutive indices.
Details
This function is useful when working with indices arranged in fixed-size
groups, where each group can be referenced by a single index. For example, if
indices are structured in chunks of 3, calling this function with n = 3
will map the corresponding groups of 3 consecutive indices for the given
input indices, see the examples.
Examples
# Example: Map indices based on groups of 3
map_indices(c(1, 3, 5), 3)
#> [1] 1 2 3 7 8 9 13 14 15
