-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a function to compute peak step accumulation metrics.
- Loading branch information
Showing
3 changed files
with
55 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#' Compute mean step accumulation (per min) from a given number of the best continous | ||
#' or discontinuous minutes | ||
#' | ||
#' @param x A vector of steps data, each value corresponding to a total of steps | ||
#' in a minute. | ||
#' @param n An integer value setting the number of minutes to be used to compute | ||
#' the metric. | ||
#' | ||
#' @return A numeric value. | ||
#' | ||
compute_peak_step_acc <- function(x, n) { | ||
|
||
vec_length <- length(head(sort(x, decreasing = TRUE), n = n)) | ||
|
||
if (vec_length < n) {NA} | ||
else { | ||
round(mean(head(sort(x, decreasing = TRUE), n = n), na.rm = TRUE), 2) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.