Creates a summary table of the selected mechanical loading variables including the number of peaks, the minimum, maximum, mean and standard deviation values of these peaks and also the number of peaks inside a given magnitude range. The summaries can be displayed by day or as a daily average.
Usage
summarise_loading(
data,
variable,
vector,
daily_average = TRUE,
ranges_acc = NULL,
ranges_grf = NULL,
ranges_lr = NULL,
save_summary = FALSE
)
Arguments
- data
An
impactr_peaks
object, as obtained with find_peaks() and/or predict_loading().- variable
A character vector indicating the variable to summarise. Can be either "acc" (for the acceleration peaks), "grf" (for the ground reaction force peaks), "lr" (for the loading rate peaks) or "all" (for all variables).
- vector
A character string indicating which vector to use to create the summaries. Can be "resultant", "vertical" or "all".
- daily_average
Create a daily average summary? Can be
TRUE
(default) orFALSE
.- ranges_acc, ranges_grf, ranges_lr
A numeric vector to specify ranges in which to count the peaks. E.g., If
ranges_acc = c(1, 2, 3)
, it will summarise the number of acceleration peaks from 1 to 2g, from 2 to 3g and above 3g. Set toNULL
(default) if no summary by range will be provided.- save_summary
Indicates whether or not to save the summary to a csv file(s). Defaults to
FALSE
. Provide a valid path to a directory as a character string to save all generated summaries.
Examples
# Ensure that {accdata} package is available before running the example.
# If it is not, run install_accdata() to install the required package.
if (requireNamespace("accdata", quietly = TRUE)) {
data <- import_dataset("daily_acc_3d")
data <- remove_nonwear(data)
data <- filter_acc(data)
data <- find_peaks(data, vector = "vertical")
summarise_loading(
data,
variable = "acc", vector = "vertical",
ranges_acc = c(1, 2, 3, 4, 5)
)
}
#> $`Summary per day`
#> # A tibble: 3 × 15
#> filename date weekday measurement_day variable n_peaks min_peaks
#> <chr> <date> <chr> <int> <chr> <dbl> <dbl>
#> 1 daily_acc_3d.csv 2016-01-20 Wednes… 1 vertica… 2844 1.3
#> 2 daily_acc_3d.csv 2016-01-21 Thursd… 2 vertica… 2420 1.3
#> 3 daily_acc_3d.csv 2016-01-22 Friday 3 vertica… 2366 1.3
#> # … with 8 more variables: max_peaks <dbl>, mean_peaks <dbl>, sd_peaks <dbl>,
#> # n_peaks_1_to_2_g <dbl>, n_peaks_2_to_3_g <dbl>, n_peaks_3_to_4_g <dbl>,
#> # n_peaks_4_to_5_g <dbl>, n_peaks_above_5_g <dbl>
#>
#> $`Daily average`
#> # A tibble: 1 × 12
#> filename variable n_peaks min_peaks max_peaks mean_peaks sd_peaks
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 daily_acc_3d.csv vertical_pea… 2543.33 1.3 5.76 1.59 0.35
#> # … with 5 more variables: n_peaks_1_to_2_g <chr>, n_peaks_2_to_3_g <chr>,
#> # n_peaks_3_to_4_g <chr>, n_peaks_4_to_5_g <chr>, n_peaks_above_5_g <chr>
#>