Learn R Programming

RBERT (version 0.1.11)

.get_actual_index: Standardize Indices

Description

Convert negative indices to positive ones. Use the convention that vec[[-1L]] signifies the last element of vec, vec[[-2L]] signifies the second-to-last element of vec, and so on. 1-based indexing is assumed. Values of zero, or out-of-range indices, will be rejected.

Usage

.get_actual_index(index, length)

Arguments

index

Integer; the index to normalize.

length

Integer; the length of the vector or list we are indexing.

Value

The "actual" integer index, between 1 and length, inclusive.