seq_events: Generate Sequential Events

View source: R/event_creation.R

seq_eventsR Documentation

Generate Sequential Events

Description

Generates groups of regularly sequenced events fitted to the specified intervals. Intended for use as bins with sample_events.

Usage

seq_events(coverage, length.out = NULL, by = NULL, adaptive = FALSE)

Arguments

coverage

An event table specifying the non-overlapping intervals to which the event sequences will be fitted. Gaps in coverage do not count towards event length. Points in the coverage are currently ignored.

length.out

The number of events in each sequence. Event lengths are chosen such that they evenly divide the coverage.

by

The length of the events in each sequence. Ignored if length.out is defined. When the length does not evenly divide the coverage, a shorter event is appended to the end of the sequence.

adaptive

If TRUE, events are adjusted locally so that a whole number of events fit within each coverage interval, preserving breaks and gaps.

Value

An endpoint-only event table with an additional group field if the length of length.out or by is > 1.

See Also

event_range, event_coverage, and fill_event_gaps for building a coverage from an existing event table.

Examples

e <- events(c(0, 20, 40), c(10, 30, 45))
no.gaps <- event_range(e)
has.gaps <- event_coverage(e)
seq_events(no.gaps, by = 10)                           # unequal length (last is shorter)
seq_events(no.gaps, by = 10, adaptive = TRUE)          # equal length (11.25)
seq_events(no.gaps, length.out = 4)                    # equal length (11.25)
seq_events(has.gaps, length.out = 4, adaptive = FALSE) # equal coverage (11.25), straddling gaps
seq_events(has.gaps, length.out = 4, adaptive = TRUE)  # unequal coverage, fitted to gaps
seq_events(no.gaps, length.out = c(2, 4))              # "group" column added

ezwelty/linbin documentation built on April 19, 2023, 8:41 a.m.