R/simData.R

#' Simulate HeavySet export data
#'
#' This function simulates HeavySet export data. The six columns are `date`, `workoutName`, `exerciseName`, `reps`, `weightKg`, `weightLb`, `notes`. Dates, reps and weight is randomly generated. The Workout is based on the following workout routine:
#'
#' **Full Body - A**
#'
#' 3×5 Barbell Rows
#'
#' 3×5 Bench Press
#'
#' 3×5 Squats
#'
#' **Full Body - B**
#'
#' 3×5 Chinups
#'
#' 3×5 Overhead Press
#'
#' 3×5 Deadlifts
#'
#' @param repeats The number of times to repeat workout routine.
#' @param seed Set the seed for reproduction
#' @return data.frame
#'
#' @export
#'
#' @examples
#' simData(repeats = 25)
simData <- function(repeats = 1, seed = 1) {
  set.seed(seed)
  df <- data.frame(
    date = rep(Sys.Date() + sort(
      sample(1:(repeats * 10), (repeats * 2), replace = F)
    ), each = 9),
    workoutName = rep(c(
      rep("Full Body - A", 9), rep("Full Body - B", 9)
    ), repeats),
    exerciseName = rep(c(
      rep("Barbell Row", 3),
      rep("Bench Press", 3),
      rep("Squat", 3),
      rep("Chin Up", 3),
      rep("Overhead Press", 3),
      rep("Deadlift", 3)
    ), repeats),
    reps = sample(2:5, repeats * 18, replace = TRUE),
    weightKg = 2.5 * round(sample(35:65,
      repeats * 18,
      replace = TRUE
    ) / 2.5),
    notes = rep("", repeats * 18),
    stringsAsFactors = T,
    check.names = F
  )
  # Convert kg to lb
  df$weightLb <- df$weightKg * 2.20462262
  df <- df[, c(1:5, 7, 6)]

  # TODO(MJABOER): Remove random rows BY GROUP, to show that the programm was not always fully run
  df <- df[-sample(1:nrow(df), repeats * 2), ]
  df <- addHSclass(df)
  return(df)
}
MarijnJABoer/HeavySetR documentation built on May 22, 2019, 5:31 p.m.