View source: R/extract_states.R
extract_states | R Documentation |
Extracts a state from a dataset and provides their start and end times, as well as duration and epoch. The state does not have to exist in the dataset, but can be dynamically created. Extracted states can have group-dropping disabled, meaning that summaries based on the extracted states show empty groups as well.
extract_states(
data,
State.colname,
State.expression = NULL,
Datetime.colname = Datetime,
handle.gaps = FALSE,
epoch = "dominant.epoch",
drop.empty.groups = TRUE,
group.by.state = TRUE
)
data |
A light logger dataset. Expects a dataframe. |
State.colname |
The variable or condition to be evaluated for state
exctration. Expects a symbol. If it is not part of the data, a
|
State.expression |
If |
Datetime.colname |
Column name that contains the datetime. Defaults to "Datetime" which is automatically correct for data imported with LightLogR. Expects a symbol. |
handle.gaps |
Logical whether the data shall be treated with
|
epoch |
The epoch to use for the gapless sequence. Can be either a
|
drop.empty.groups |
Logical. Should empty groups be dropped? Only works
if |
group.by.state |
Logical. Should the output be automatically be grouped by the new state? |
a dataframe with one row per state instance. Each row will consist of the original dataset grouping, the state column. A state.count column, start and end Datetimes, as well as a duration of the state
#summarizing states "photoperiod"
states <-
sample.data.environment |>
add_photoperiod(c(48.52, 9.06)) |>
extract_states(photoperiod.state)
states |> head(2)
states |> tail(2)
states |> summarize_numeric(c("state.count", "epoch"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.