nset: Find indexes for n identical elements

View source: R/nset.R

nsetR 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)


StratigrapheR documentation built on July 9, 2023, 6:02 p.m.