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
# \donttest{
# 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 = 1:5
)
}
#> $`Summary per day`
#> # A tibble: 3 × 15
#> filename date weekday measu…¹ varia…² n_peaks min_p…³ max_p…⁴ mean_…⁵
#> <chr> <date> <chr> <int> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 daily_acc_… 2016-01-20 Wednes… 1 vertic… 2844 1.3 4.92 1.63
#> 2 daily_acc_… 2016-01-21 Thursd… 2 vertic… 2420 1.3 6.29 1.59
#> 3 daily_acc_… 2016-01-22 Friday 3 vertic… 2366 1.3 6.08 1.55
#> # … with 6 more variables: 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>, and abbreviated variable names ¹measurement_day,
#> # ²variable, ³min_peaks, ⁴max_peaks, ⁵mean_peaks
#> # ℹ Use `colnames()` to see all variable names
#>
#> $`Daily average`
#> # A tibble: 1 × 12
#> filename varia…¹ n_peaks min_p…² max_p…³ mean_…⁴ sd_pe…⁵ n_pea…⁶ n_pea…⁷
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 daily_acc_3d.… vertic… 2543.33 1.3 5.76 1.59 0.35 2332.67 188.33
#> # … with 3 more variables: n_peaks_3_to_4_g <chr>, n_peaks_4_to_5_g <chr>,
#> # n_peaks_above_5_g <chr>, and abbreviated variable names ¹variable,
#> # ²min_peaks, ³max_peaks, ⁴mean_peaks, ⁵sd_peaks, ⁶n_peaks_1_to_2_g,
#> # ⁷n_peaks_2_to_3_g
#> # ℹ Use `colnames()` to see all variable names
#>
# }