make_index_vector: Make a vector of stretches of indices of contigs satisfying a...

make_index_vectorR Documentation

Make a vector of stretches of indices of contigs satisfying a predicate vector

Description

Useful together with split(), see example

Usage

make_index_vector(vec, predicate = !is.na(vec))

Arguments

vec

A vector

predicate

A TRUE/FALSE vector of same length as vec, defaults to !is.na(vec)

Value

vector of indices

Examples

tosplit <- c(TRUE, TRUE, TRUE, NA, NA, TRUE, TRUE, NA,
TRUE, TRUE, TRUE, TRUE)
(index <- make_index_vector(tosplit))
split(tosplit[!is.na(tosplit)], index)

set.seed(1234)
(tosplit2 <- rnorm(10))
make_index_vector(tosplit2, tosplit2 > 0)


powestermark/pwrutilities documentation built on Dec. 28, 2024, 4:44 a.m.