runs: Calculate positional information about 'TRUE'-runs

runsR Documentation

Calculate positional information about TRUE-runs

Description

Calculate positional information about TRUE-runs

Usage

calc_starts(x)

calc_runs(x)

Arguments

x

A vector. Values are coerced to logical values.

Value

For calc_starts(): an integer vector with start position(s) of TRUE-runs.

For calc_runs(): a list with integer sequences of the position(s) of TRUE-runs.

Examples

calc_starts(c(0, 1, 1, 0, 0)) ## expected: 2
calc_runs(c(0, 1, 1, 0, 0)) ## expected: list(2:3)
calc_starts(c(1, 1, 0, 0)) ## expected: 1
calc_runs(c(1, 1, 0, 0)) ## expected: list(1:2)
calc_starts(c(1, 1, 0, 0, 1, 1)) ## expected: 1 5
calc_runs(c(1, 1, 0, 0, 1, 1)) ## expected: list(1:2, 5:6)
calc_starts(c(1.5, 2, 0, 0, 15, 3.5)) ## expected: 1 5
calc_runs(c(1.5, 2, 0, 0, 15, 3.5)) ## expected: list(1:2, 5:6)
calc_starts(c(0, 0)) ## expected: integer(0)
calc_runs(c(0, 0)) ## expected: list()


DrylandEcology/rSW2utils documentation built on Dec. 9, 2023, 10:44 p.m.