make_index_vector | R Documentation |
Useful together with split(), see example
make_index_vector(vec, predicate = !is.na(vec))
vec |
A vector |
predicate |
A TRUE/FALSE vector of same length as vec, defaults to !is.na(vec) |
vector of indices
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.