Learn R Programming

matrixStats (version 0.53.1)

validateIndices: Validate indices

Description

Computes validated positive indices from given indices.

Usage

validateIndices(idxs = NULL, maxIdx, allowOutOfBound = TRUE)

Arguments

idxs

A integer vector. If NULL, all indices are considered.

maxIdx

The possible max index.

allowOutOfBound

Allow positive out of bound to indicate NA.

Value

Returns a validated integers list indicating the indices.

Examples

Run this code
# NOT RUN {
idxs <- validateIndices(c(-4, 0, -3, -1), 5)  # [2, 5]

idxs <- validateIndices(c(4, 4, 8, 2, 3), 8)  # [4, 4, 8, 2, 3]
# }

Run the code above in your browser using DataLab