Learn R Programming

oeli (version 0.7.1)

map_indices: 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)

Value

An integer

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

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.

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

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

Run the code above in your browser using DataLab