#' Get rep and weight records per exercise
#'
#' This function extracts rep and weight records for an exercise
#'
#' @param df A dataframe
#' @param exercise Select the exercise to see records. If `NULL` all exercises are shown.
#'
#' @return ggplot object
#'
#' @export
#'
#' @importFrom dplyr select group_by summarise_at vars filter
#'
#' @examples
#' df <- simData(2, 1)
#' getRecords(df)
getRecords <-
function(df, exercise = NULL) {
records <- df %>%
dplyr::select(date, exerciseName, reps, weightKg) %>%
dplyr::group_by(exerciseName) %>%
dplyr::summarise_at(dplyr::vars(reps, weightKg), max)
if (!is.null(exercise)) {
records <- records %>%
dplyr::filter(exerciseName %in% exercise) %>%
droplevels() # Makes sure that the tests work
}
return(records)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.