l_which: Logical which

Description Usage Arguments Details Value Examples

View source: R/l_which.r

Description

Inverse of which. Converts an array of numeric or character indices to a logical index array. This function is useful if you need to perform logical operation on an index array but are only given numeric indices.

Usage

1
l_which(idx, nms = seq_len(len), len = length(nms), useNames = TRUE)

Arguments

idx

Numeric or character indices.

nms

Array of names or a sequence. Required if idx is a character array

len

Length of output array. Alternative to nms if idx is numeric

useNames

Use the names of nms or idx

Details

Either nms or len has to be specified.

Value

Logical vector of length len or the same length as nms

Examples

1
2
all(l_which(2, len = 3L) == c(FALSE, TRUE, FALSE))
all(l_which(c('a', 'c'), letters[1:3]) == c(TRUE, FALSE, TRUE))

destiny documentation built on Nov. 8, 2020, 7:38 p.m.

Related to l_which in destiny...