spell.length.max: Maximum spell length

Description Usage Arguments Details Value See Also Examples

View source: R/climdex.r

Description

This function returns the longest string of days which exceed or are below the given threshold.

Usage

1
spell.length.max(daily.prec, date.factor, threshold, op, spells.can.span.years)

Arguments

daily.prec

Data to compute index on.

date.factor

Date factor to split by.

threshold

The threshold to compare to.

op

The operator to use to compare data to threshold.

spells.can.span.years

Whether spells can span years.

Details

This routine compares data to the threshold using the given operator, generating a series of TRUE or FALSE values. It then computes the lengths of sequences of TRUE values (spells) and chooses the longest spell in each period (as defined by date.factor).

The spells.can.span.years option controls whether spells must always terminate at the end of a period, or whether they may continue until the criteria ceases to be met or the end of the data is reached. The default for fclimdex is TRUE.

Value

A timeseries of maximum spell lengths for each period.

See Also

climdex.cdd.

Examples

1
2
3
4
5
6
7
8
prec.dat <- c(0.1, 3.0, 4.3, 1.9, 1.3, 6.0, 0, 0, 4.0, 1)
phony.date.factor <- factor(rep(1:2, each=5))

## With spells spanning years...
cwd <- spell.length.max(prec.dat, phony.date.factor, 1, ">=", TRUE)

## Without spells spanning years...
altcwd <- spell.length.max(prec.dat, phony.date.factor, 1, ">=", FALSE)

Example output

Loading required package: PCICt

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