crop_events: Crop Events

Description Usage Arguments See Also Examples

View source: R/event_operations.R

Description

Crops events to the specified intervals. Events are cut at interval endpoints and any whole or partial events lying outside the intervals are removed.

Usage

1
crop_events(e, crops, scaled.cols = NULL)

Arguments

e

An event table.

crops

An event table specifying the intervals for cropping. Point intervals are allowed, and will create new point events where they intersect the interior, but not the endpoints, of line events.

scaled.cols

Names or indices of the columns of the event table to be rescaled after cutting (see cut_events). Names are interpreted as regular expressions (regex) matching full column names.

See Also

cut_events for only cutting events.

Examples

1
2
3
4
5
6
e <- events(c(0, 10, 20), c(10, 20, 30), x = 10)
crop_events(e, events(c(0, 15)))
crop_events(e, events(c(0, 5, 15)))
crop_events(e, events(c(0, 5, 15)), scaled.cols = "x")
crop_events(e, events(c(0, 5, 5, 15)), scaled.cols = "x")   # creates new points inside lines
crop_events(e, events(c(0, 10, 10, 15)), scaled.cols = "x") # but not at line event endpoints

Example output

  from to  x
1    0 10 10
2   10 15 10
    from to  x
1      0  5 10
1.1    5 10 10
2     10 15 10
    from to x
1      0  5 5
1.1    5 10 5
2     10 15 5
    from to x
1      0  5 5
1.1    5  5 0
1.2    5 10 5
2     10 15 5
  from to  x
1    0 10 10
2   10 15  5

linbin documentation built on April 20, 2021, 5:07 p.m.