getSessions: Creates a unique ID for consecutive matching values in a...

View source: R/General_Functions.R

getSessionsR Documentation

Creates a unique ID for consecutive matching values in a series.

Description

This function is useful for createing a unique id for all dives or trips.

Usage

getSessions(value, ignore = FALSE, ignoreValue = NULL, maxSession = Inf)

Arguments

value

A vector containing the values you want to create IDs for, can be any data type.

ignore

Use TRUE if there are values that should not get IDs.

ignoreValue

a singe value or list of values to ignore when assigning IDs.

maxSession

A numeric value indicating the maximum number of repeating values that should be assigned the same ID. Defaults to Inf for no limit.

Value

A numeric vector of IDs

Examples


# example with numeric input, that ignores 0
tt <- c(0, 0, 1, 1, 1, 1, 3, 3, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 2, 2)
getSessions(value = tt, maxSession = Inf, ignore = TRUE, ignoreValue = 0)

# example with text input
tt <- c('fly', 'fly', 'fly', 'dive', 'dive', 'dive', 'fly', 'fly', 'fly',
'colony', 'colony', 'colony','fly','fly')
getSessions(value = tt, ignore = FALSE)

# example with text input that does not assign ID to colony
getSessions(value = tt, ignore = TRUE, ignoreValue = 'colony')

allisonglider/seabiRds documentation built on Feb. 14, 2025, 7:37 a.m.