View source: R/summarize_numeric.R
summarize_numeric | R Documentation |
This simple helper function was created to summarize episodes of gaps, clusters, or states, focusing on numeric variables. It calculates mean values for all numeric columns and handles Duration objects appropriately.
Despite its name, the function actually summarizes all double columns, which is more inclusive compared to just numeric columns.
summarize_numeric(
data,
remove = NULL,
prefix = "mean_",
na.rm = TRUE,
complete.groups.on = NULL,
add.total.duration = TRUE,
durations.dec = 0,
Datetime2Time = TRUE
)
summarise_numeric(
data,
remove = NULL,
prefix = "mean_",
na.rm = TRUE,
complete.groups.on = NULL,
add.total.duration = TRUE,
durations.dec = 0,
Datetime2Time = TRUE
)
data |
A dataframe containing numeric data, typically from
|
remove |
Character vector of columns removed from the summary. |
prefix |
A prefix to add to the column names of summarized metrics. Defaults to "mean_". |
na.rm |
Whether to remove NA values when calculating means. Defaults to TRUE. |
complete.groups.on |
Column name that, together with grouping variables,
can be used to provide a complete set. For example, with
|
add.total.duration |
Logical, whether the total duration for a given
group should be calculated. Only relevant if a column |
durations.dec |
Numeric of number of decimals for the mean calculation of durations and times. Defaults to 0. |
Datetime2Time |
Logical of whether POSIXct columns should be transformed
into hms(time) columns, which is usually sensible for averaging (default is
|
A dataframe containing the summarized metrics.
# Extract clusters and summarize them
dataset <-
sample.data.environment %>%
aggregate_Datetime(unit = "15 mins") |>
extract_clusters(MEDI > 1000)
#input to summarize_numeric
dataset |> utils::head()
#output of summarize_numeric (removing state.count and epoch from the summary)
dataset |> summarize_numeric(c("state.count", "epoch"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.