get.series.lengths.at.ends: Get series length at ends

Description Usage Arguments Details Value Examples

View source: R/climdex.r

Description

This function takes a series of boolean values and returns a list of integers of the same length corresponding to the lengths at the ends of sequences of TRUE values.

Usage

1

Arguments

x

Sequence of booleans.

na.value

Value to replace NAs with.

Details

It can often be useful to know how long a series of boolean values is. This function provides a method of knowing where and how long such sequences are.

Value

A vector consisting of the lengths of sequences of TRUE values at the location of the last TRUE value in the sequence, and zeroes elsewhere.

Examples

1
2
3
## Get lengths of sequences of TRUE values in a sequence
series.lengths <- get.series.lengths.at.ends(c(TRUE, TRUE, TRUE, FALSE,
TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE))

climdex.pcic documentation built on March 26, 2020, 7:17 p.m.