eventProcessing: Event Processing

eventNumR Documentation

Event Processing

Description

Computes the event number eventNum, the length of events eventLen, or the sequence number for individual observations within an event eventSeq. Added from smwrBase.

Usage

eventNum(event, reset = FALSE, na.fix = FALSE)

eventSeq(eventno)

eventLen(eventno, summary = FALSE)

Arguments

event

a logical vector where TRUE indicates that an event occurred. Missing values are treated as instructed by na.fix.

reset

a logical value indicating whether the event is assumed to continue until the next event, or only while event is TRUE.

na.fix

the value to use where event has missing values (NAs).

eventno

an integer vector indicating the event number. Generally the output from the eventNum function.

summary

a logical value, controlling output. See Value for details.

Value

The function eventNum returns an integer vector the same length as event indicating the event sequence number.

The function eventLen returns an integer vector the same length as eventno indicating the sequence length of the event if summary is FALSE, or a named integer vector indicating the sequence length of each event if summary is TRUE.

The function eventSeq returns an integer vector the same length as eventno indicating the sequence number of each element in the event.

Examples


## Notice the difference caused by setting reset to TRUE
eventNum(c(TRUE,TRUE,FALSE,FALSE,TRUE,FALSE))
eventNum(c(TRUE,TRUE,FALSE,FALSE,TRUE,FALSE), reset=TRUE)

## Notice the difference caused by setting reset to TRUE
eventSeq(eventNum(c(TRUE,TRUE,FALSE,FALSE,TRUE,FALSE)))
eventSeq(eventNum(c(TRUE,TRUE,FALSE,FALSE,TRUE,FALSE), reset=TRUE))

## Notice the difference caused by setting reset to TRUE
eventLen(eventNum(c(TRUE,TRUE,FALSE,FALSE,TRUE,FALSE), reset=TRUE))
## This is an example of the summary option
eventLen(eventNum(c(TRUE,TRUE,FALSE,FALSE,TRUE,FALSE), reset=TRUE), summary=TRUE)

leppott/baytrends documentation built on Nov. 2, 2024, 6:42 p.m.