map_indices: Map indices

View source: R/map_indices.R

map_indicesR Documentation

Map indices

Description

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.

Usage

map_indices(indices, 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.

Value

An integer vector, containing the mapped indices according to the specified group size.

See Also

Other vector helpers: check_numeric_vector(), check_probability_vector(), chunk_vector(), insert_vector_entry(), match_numerics(), permutations(), split_vector_at(), subsets(), vector_occurrence()

Examples

# Example: Map indices based on groups of 3
map_indices(c(1, 3, 5), 3)

oeli documentation built on April 3, 2025, 9:29 p.m.