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(..., ignore_case = FALSE, fixed = FALSE)
by_lap(...)
by_sample(...)
... |
Specify start or end boundaries.
|
ignore_case |
For |
fixed |
For |
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.
Multiple specification types can be combined for a single boundary with
list() (e.g. list(by_time(30), by_label("go"))). Resolved
boundary times are concatenated in the order supplied. Combined
specifications must use the by_ helpers directly: raw values are
ignored with a warning.
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)
## combine multiple specification types
extract_intervals(
data,
start = list(by_lap(2), by_time(400)),
end = by_sample(1500)
)
## simulate event_channel with character label match
data$event <- NA_character_
data$event[c(1000, 1001)] <- c("start", "lap.1")
data <- create_mnirs_data(data, event_channel = "event")
## case-insensitive label match
extract_intervals(data, start = by_label("START", ignore_case = TRUE))
## literal-string label match (regex metacharacters treated as text)
extract_intervals(data, start = by_label("lap.1", fixed = TRUE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.