number.days.op.threshold: Number of days (less than, greater than, etc) a threshold

Description Usage Arguments Details Value Examples

View source: R/climdex.r

Description

Produces sums of values that exceed (or are below) the specified threshold.

Usage

1
number.days.op.threshold(temp, date.factor, threshold, op = "<")

Arguments

temp

Sequence temperature values.

date.factor

Factor to aggregate by.

threshold

Threshold to use.

op

Operator to use for comparison.

Details

This function takes a data series, a threshold, an operator, and a factor to aggregate by. It uses the operator to compare the threshold to the data series, creating a series of booleans, then sums the booleans according to the factor.

Value

A vector consisting of the number of values that meet the criteria in the given time period (as specified by date.factor).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
library(PCICt)

## Parse the dates into PCICt.
tmax.dates <- as.PCICt(do.call(paste, ec.1018935.tmax[,c("year",
"jday")]), format="%Y %j", cal="gregorian")
tmin.dates <- as.PCICt(do.call(paste, ec.1018935.tmin[,c("year",
"jday")]), format="%Y %j", cal="gregorian")
prec.dates <- as.PCICt(do.call(paste, ec.1018935.prec[,c("year",
"jday")]), format="%Y %j", cal="gregorian")

## Load the data in.
ci <- climdexInput.raw(ec.1018935.tmax$MAX_TEMP,
ec.1018935.tmin$MIN_TEMP, ec.1018935.prec$ONE_DAY_PRECIPITATION,
tmax.dates, tmin.dates, prec.dates, base.range=c(1971, 2000))

## Calculate frost days.
fd <- number.days.op.threshold(ci@data$tmin,
                               ci@date.factors$annual, 0, "<")

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