nset {StratigrapheR} | R Documentation |
Find indexes for n identical elements
Description
For a given vector, this function gives the indexes of identical sets for a given number of repetitions
Usage
nset(x, n, first = T, warn = T)
Arguments
x |
a vector, normally with repeated values |
n |
the amount of repetitions that needs to be identified |
first |
whether to take the first repetitions (T; is the default), or the last ones (F) |
warn |
whether to warn if NA values are generated due to the lack of right amount of repetitions |
Examples
ids <- c(rep("A", 4), rep("B", 6), rep("C", 2))
val <- paste(ids, c(1:4, 1:6, 1:2), sep = "")
nset(ids, 3, warn = FALSE)
matrix(val[nset(ids, 3, warn = FALSE)], ncol = 3)
matrix(val[nset(ids, 3, first = FALSE, warn = FALSE)], ncol = 3)
[Package StratigrapheR version 1.3.1 Index]