aim training

Author

jack

import and clean spreadsheet

library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.4     ✔ purrr   1.0.2
✔ tibble  3.2.1     ✔ dplyr   1.1.4
✔ tidyr   1.3.1     ✔ stringr 1.5.1
✔ readr   2.1.3     ✔ forcats 1.0.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
library(googlesheets4)

gs4_auth('jackaolmstead@gmail.com')

# read in google sheet
aimsheet <- read_sheet('https://docs.google.com/spreadsheets/d/1Zla2ctJOzANNtOds-ik6v3cV0bC2uw2FLZoisXgZ_FA/edit#gid=0')
✔ Reading from "AimLabs sheet".
✔ Range 'Results'.
# identify first row with NA value and delete all rows below()
aimsheet <- aimsheet %>% 
  slice(1:which(is.na(aimsheet$Date)) - 1)
Warning in 1:which(is.na(aimsheet$Date)): numerical expression has 85 elements:
only the first used
# delete columns with 'AVG' at end of colname
aimsheet <- aimsheet %>% 
  select(-contains('AVG'))

# remove all spaces from colnames
colnames(aimsheet) <- gsub(' ', '', colnames(aimsheet))
aimsheet
# A tibble: 5 × 27
    Day Date                 Time SmoothStrafe1 SmoothStrafe2 SmoothStrafe3
  <dbl> <dttm>              <dbl>         <dbl>         <dbl>         <dbl>
1     1 2024-02-03 00:00:00    NA          2085          1846          1934
2     2 2024-02-05 00:00:00    NA          2257          2222          1970
3     3 2024-02-06 00:00:00    NA          1902          2227          2148
4     4 2024-02-07 00:00:00  2200          1961          1904          2144
5     5 2024-02-08 00:00:00  2100          2086          1836          1931
# ℹ 21 more variables: AdjustTrack1 <dbl>, AdjustTrack2 <dbl>,
#   AdjustTrack3 <dbl>, `3TWide1` <dbl>, `3TWide2` <dbl>, `3TWide3` <dbl>,
#   StaticSmall1 <dbl>, StaticSmall2 <dbl>, StaticSmall3 <dbl>,
#   `5Sphere1` <dbl>, `5Sphere2` <dbl>, `5Sphere3` <dbl>, SmallFlicks1 <dbl>,
#   SmallFlicks2 <dbl>, SmallFlicks3 <dbl>, DynamicReflex1 <dbl>,
#   DynamicReflex2 <dbl>, DynamicReflex3 <dbl>, Speedswitch1 <dbl>,
#   Speedswitch2 <dbl>, Speedswitch3 <dbl>

Let’s rearrange the data so it’s in a more tidy format.

aimsheet <- aimsheet |> 
  pivot_longer(cols = -c(Day, Date, Time), names_to = "task", values_to = "score") |> 
  mutate(trial = str_sub(task, -1, -1)) |>
  mutate(task = str_sub(task, 1, -2)) |> 
  relocate(trial, .after = task)

aimsheet
# A tibble: 120 × 6
     Day Date                 Time task         trial score
   <dbl> <dttm>              <dbl> <chr>        <chr> <dbl>
 1     1 2024-02-03 00:00:00    NA SmoothStrafe 1      2085
 2     1 2024-02-03 00:00:00    NA SmoothStrafe 2      1846
 3     1 2024-02-03 00:00:00    NA SmoothStrafe 3      1934
 4     1 2024-02-03 00:00:00    NA AdjustTrack  1      2616
 5     1 2024-02-03 00:00:00    NA AdjustTrack  2      2709
 6     1 2024-02-03 00:00:00    NA AdjustTrack  3      2692
 7     1 2024-02-03 00:00:00    NA 3TWide       1       942
 8     1 2024-02-03 00:00:00    NA 3TWide       2       962
 9     1 2024-02-03 00:00:00    NA 3TWide       3       942
10     1 2024-02-03 00:00:00    NA StaticSmall  1       935
# ℹ 110 more rows

Now let’s plot the data.

p <- ggplot(aimsheet) +
  aes(x = Date, y = score, color=task) +
  geom_point() +
  geom_smooth() +
  facet_grid(row=vars(task), scales = "free_y") +
  # theme(aspect.ratio = 1/5) +
  labs(title = "Woohoojin 90-day aim training challenge",
       y = "Score",
       x = "") +
  # remove yticks but set ylabel to 'Score'
  theme(axis.text.y = element_blank(),
        axis.ticks.y = element_blank(),
        axis.title.y = element_text(margin = margin(t = 0, r = 20, b = 0, l = 0))) +
  theme(legend.position = "none")
  
print(p)
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'