-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnerdOut.Rmd
108 lines (85 loc) · 2.8 KB
/
nerdOut.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
title: "FitNotes"
author: "Roberto Siani"
date: "9/10/2020"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(ggplot2)
library(tidyverse)
library(viridis)
library(plotly)
library(lubridate)
library(skimr) # for descriptive statistics
library(ggpubr)
setwd("~/LIBRARY/XLSX/FitNotes/")
```
### IMPORT CSV
```{r}
DF = read.csv("FitNotes_Export_2020_09_18_08_47_10.csv") %>% # import
filter(Reps != 0 & # filter 1RM failed attempt
Exercise %in% c("Decline Barbell Bench Press",
"Sumo Deadlift",
"Barbell Squat",
"Overhead Press")) %>% # select your strength metrics
select(!c(Distance, Distance.Unit, Time)) %>%
mutate(Volume = `Weight..kgs.` * Reps, # calculate volume
Date = as.Date(Date,
format = "%Y-%m-%d"), # reformat dates
OneRM = `Weight..kgs.` / ( 1.0278 - 0.0278 * Reps ), # calculate 1RepMax with Brzycki's Formula (https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3525823/)
Perc1RM = `Weight..kgs.` / OneRM * 100) %>% # calculate percentage of 1RepMax used
arrange(Exercise) # arrange by any variable, I prefer having the exercises grouped together
skimmed = skim(DF)
```
### VISUAL
```{r}
visual = ggplot(DF, aes(x = Date,
y = OneRM,
color = Exercise)) +
geom_smooth(method = "lm",
aes(fill = Exercise)) +
geom_point(aes(y = OneRM,
alpha = Perc1RM)) +
theme_minimal() +
theme(panel.grid.minor = element_blank(),
axis.text.x = element_text(angle = 45,
vjust = 1.25,
hjust = 1),
axis.title.x = element_blank(),
text = element_text(size = 15),
legend.position = "none") +
scale_x_date(Date,
date_breaks = "5 day",
breaks = waiver()) +
facet_wrap(DF$Exercise) +
scale_color_viridis(discrete = T) +
scale_fill_viridis(discrete = T)
visual
ggplotly(visual)
```
```{r}
lDF = DF %>%
select(!c(Volume, Reps)) %>%
pivot_longer(cols = 4:6,
names_to = "Metric",
values_to = "Value")
visual2 = ggplot(lDF,
aes(x = Metric,
y = Value,
fill = Exercise,
alpha = 0.75)) +
geom_boxplot() +
theme_minimal() +
facet_wrap("Exercise") +
theme(panel.grid.minor = element_blank(),
axis.text.x = element_text(angle = 45,
vjust = 1.25,
hjust = 1),
axis.title.x = element_blank(),
text = element_text(size = 15)) +
scale_fill_viridis(discrete = T) +
theme(legend.position = "none")
visual2
ggplotly(visual2)
```