View source: R/extract_interval_helpers.R
| by_time | R Documentation |
Helper functions to define interval start or end boundaries for
extract_intervals().
by_time(...)
by_label(...)
by_lap(...)
by_sample(...)
... |
Specify start or end boundaries.
|
These helpers can be used explicitly for arguments start/end, or raw
values can be passed directly:
Numeric -> by_time()
Character -> by_label(),
Explicit integer (e.g. 2L) -> by_lap().
Use by_sample() explicitly for sample indices.
An object of class "mnirs_interval" for use with the start
and end arguments of extract_intervals().
## read example data
data <- read_mnirs(
example_mnirs("train.red"),
nirs_channels = c(
smo2_left = "SmO2 unfiltered",
smo2_right = "SmO2 unfiltered"
),
time_channel = c(time = "Timestamp (seconds passed)"),
event_channel = c(lap = "Lap/Event"),
zero_time = TRUE,
verbose = FALSE
)
## start and end by time
extract_intervals(data, start = by_time(66), end = by_time(357))
## start by lap
extract_intervals(data, start = by_lap(2, 4), span = 0)
## introduce event_channel with "start" string
data$event <- NA_character_
data$event[1000] <- "start"
data <- create_mnirs_data(data, event_channel = "event")
## start by label, end by time
extract_intervals(data, start = by_label("start"), end = by_time(1500))
## multiple intervals by sample index
extract_intervals(data, start = by_sample(1000, 1500), end = by_sample(2000, 2600))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.