plotOverview <- function(df) {
# Overview (5 rows x 1 column) per week: n workouts, n exercises, n sets, n reps, volume (5 bar graphs)
df.all <- df %>%
dplyr::select(date, workoutName, exerciseName, reps, weightKg) %>%
dplyr::mutate(`Volume (kg)` = reps * weightKg)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Workouts
ggworkouts <- df.all %>%
dplyr::select(date, workoutName) %>%
dplyr::group_by(date) %>%
dplyr::mutate(Quantity = n()) %>%
dplyr::slice(1) %>%
dplyr::ungroup() %>%
dplyr::group_by(date, workoutName) %>%
dplyr::summarise(Count = n()) %>%
ggplot2::ggplot(.) +
ggplot2::geom_col(ggplot2::aes(
x = date,
y = Count,
fill = workoutName,
group = workoutName
)) +
ggplot2::scale_x_date(labels = scales::date_format("%Y %b"), breaks = "1 month") +
scale_fill_HS() +
ggplot2::theme(legend.position = "top")
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Exercises
ggexercises <- df.all %>%
dplyr::select(date, exerciseName) %>%
dplyr::group_by(date, exerciseName) %>%
dplyr::summarise(Count = n()) %>%
ggplot2::ggplot(.) +
ggplot2::geom_col(ggplot2::aes(
x = date,
y = Count,
fill = exerciseName,
group = exerciseName
)) +
# ggplot2::stat_summary(aes(x = Year),
# fun.y = sum,
# geom = "bar",
# position = "stack") +
ggplot2::scale_x_date(labels = scales::date_format("%Y %b"), breaks = "1 month") +
scale_fill_HS() +
ggplot2::theme(legend.position = "top")
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Reps
ggreps <- df.all %>%
dplyr::select(date, reps) %>%
dplyr::group_by(date, reps) %>%
dplyr::summarise(Sum = sum(reps)) %>%
ggplot2::ggplot(.) +
ggplot2::geom_col(ggplot2::aes(
x = date,
y = Sum,
fill = Sum
)) +
ggplot2::scale_x_date(labels = scales::date_format("%Y %b"), breaks = "1 month") +
scale_fill_HS(palette = "bi", discrete = FALSE) +
ggplot2::theme(legend.position = "none")
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Weight
ggweight <- df.all %>%
dplyr::select(date, weightKg) %>%
dplyr::group_by(date, weightKg) %>%
dplyr::summarise(Sum = sum(weightKg)) %>%
ggplot2::ggplot(.) +
ggplot2::geom_col(ggplot2::aes(
x = date,
y = Sum,
fill = Sum
)) +
ggplot2::scale_x_date(labels = scales::date_format("%Y %b"), breaks = "1 month") +
scale_fill_HS(palette = "bi", discrete = FALSE) +
ggplot2::theme(legend.position = "none")
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Volume
ggvolume <- df.all %>%
dplyr::select(date, `Volume (kg)`) %>%
dplyr::group_by(date, `Volume (kg)`) %>%
dplyr::summarise(Sum = sum(`Volume (kg)`)) %>%
ggplot2::ggplot(.) +
ggplot2::geom_col(ggplot2::aes(
x = date,
y = Sum,
fill = Sum
)) +
ggplot2::scale_x_date(labels = scales::date_format("%Y %b"), breaks = "1 month") +
scale_fill_HS(palette = "bi", discrete = FALSE) +
ggplot2::theme(legend.position = "none")
plots <- cowplot::plot_grid(ggworkouts,
ggexercises,
ggreps,
ggweight,
ggvolume,
nrow = 5,
align = "v"
)
return(plots)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.