View source: R/extract_metric.R
extract_metric | R Documentation |
This helper function adds metric values to an extract, like from
extract_states()
or extract_clusters()
. E.g., the average value of a
variable during a cluster or state instance might be of interest. The metrics
must be specified by the user using the ...
argument.
extract_metric(
extracted_data,
data,
identifying.colname = state.count,
Datetime.colname = Datetime,
...
)
extracted_data |
A dataframe containing cluster or state summaries,
typically from |
data |
The original dataset that produced |
identifying.colname |
Name of the column in |
Datetime.colname |
Column name that contains the datetime in |
... |
Arguments specifying the metrics to add summary. For example:
|
The original data
does not have to have the cluster/state information, but
it will be computationally faster if it does.
A dataframe containing the extracted data with added metrics.
# Extract clusters and add mean MEDI value
sample.data.environment |>
filter_Date(length = "2 days") |>
extract_clusters(MEDI > 1000) |>
extract_metric(
sample.data.environment,
"mean_medi" = mean(MEDI, na.rm = TRUE)
) |>
dplyr::select(Id, state.count, duration, mean_medi)
# Extract states and add mean MEDI value
dataset <-
sample.data.environment |>
filter_Date(length = "2 days") |>
add_photoperiod(c(48.5, 9))
dataset |>
extract_states(photoperiod.state) |>
extract_metric(dataset, mean_lux = mean(MEDI)) |>
dplyr::select(state.count, duration, mean_lux)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.