install.packages("readxl")  
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.5'
## (as 'lib' is unspecified)
install.packages("ggplot2")  
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.5'
## (as 'lib' is unspecified)
library(readxl)
library(ggplot2)

PRE <- read_excel("Engaged_Learning_Data_Clean.xlsx", sheet = "PRE")
POST <- read_excel("Engaged_Learning_Data_Clean.xlsx", sheet = "POST")

head(PRE)
## # A tibble: 6 × 6
##   Athlete Height FREQ_MED Steps_Per_Min Cadence_Height_Ratio Running_Economy
##   <chr>    <dbl>    <dbl>         <dbl>                <dbl>           <dbl>
## 1 7008NIT   1.76     2.86          171.                 97.3           4273.
## 2 5400NIT   1.84     2.87          172.                 93.7           4043.
## 3 5146NIT   1.83     3.04          183.                 99.8           3509.
## 4 4628NIT   1.78     2.97          178.                100.            4104.
## 5 5112NIT   1.78     3.02          181.                102.            3988.
## 6 5288NIT   1.74     2.94          177.                102.            4013.
head(POST)
## # A tibble: 6 × 6
##   Athlete Height FREQ_MED_POST Steps_Per_Min Cadence_Height_Ratio
##   <chr>    <dbl>         <dbl>         <dbl>                <dbl>
## 1 7008NIT   1.76          2.91          175.                 99.2
## 2 5400NIT   1.84          2.92          175.                 95.4
## 3 5146NIT   1.83          3.09          185.                101. 
## 4 4628NIT   1.78          3.01          181.                102. 
## 5 5112NIT   1.78          3.02          181.                102. 
## 6 5288NIT   1.74          2.83          170.                 97.9
## # ℹ 1 more variable: Running_Economy <dbl>
#For cadence and RE (Not used in class)- PRE
#Loess smoothed curve plot
ggplot(PRE, aes(x = Steps_Per_Min, y = Running_Economy)) +
  geom_point(alpha = 0.6) +
  geom_smooth(method = "loess", se = TRUE) +
  theme_minimal() +
  labs(
    title = "Cadence vs Running Economy- LOESS Smooth (Pre Treatment)",
    x = "Cadence",
    y = "Running Economy"
  )
## `geom_smooth()` using formula = 'y ~ x'

#Loess smoothed curve plot - POST
ggplot(POST, aes(x = Steps_Per_Min, y = Running_Economy)) +
  geom_point(alpha = 0.6) +
  geom_smooth(method = "loess", se = TRUE) +
  theme_minimal() +
  labs(
    title = "Cadence vs Running Economy- LOESS Smooth (Post Treatment)",
    x = "Cadence",
    y = "Running Economy"
  )
## `geom_smooth()` using formula = 'y ~ x'

#Scatterplot PRE
ggplot(PRE, aes(x = Cadence_Height_Ratio, y = Running_Economy)) +
  geom_point(size = 2, alpha = 0.7) +
  geom_smooth(method = "lm", se = FALSE) +
  theme_minimal() +
  labs(
    title = "Cadence-to-Height Ratio vs Running Economy (Pre Treatment)",
    x = "Cadence / Height",
    y = "Running Economy",
  )
## `geom_smooth()` using formula = 'y ~ x'

#Scatterplot POST
ggplot(POST, aes(x = Cadence_Height_Ratio, y = Running_Economy)) +
  geom_point(size = 2, alpha = 0.7) +
  geom_smooth(method = "lm", se = FALSE) +
  theme_minimal() +
  labs(
    title = "Cadence-to-Height Ratio vs Running Economy (Post Treatment)",
    x = "Cadence / Height",
    y = "Running Economy",
  )
## `geom_smooth()` using formula = 'y ~ x'