Mihkel_Study_3

library(rmcorr)
library(ggplot2)
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.0     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ lubridate 1.9.2     ✔ tibble    3.1.8
✔ purrr     1.0.1     ✔ tidyr     1.3.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors
library(readxl)
library(ggpubr)
library(lsr)

setwd("~/Research/R/Mihkel")
Data <- read_excel("Data.xlsx")
Mean_PHV <- read_excel("Mean PHV.xlsx")
PrePHV <- read_excel("PrePHV.xlsx")
New names:
• `` -> `...18`
• `` -> `...19`
• `` -> `...20`
Postphvnew <- read_excel("Postphvnew.xlsx")
New names:
• `` -> `...25`
• `` -> `...26`

Figure 1

Saving 7 x 5 in image
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
Saving 7 x 5 in image

ggplot figure all data

This visualizes the same data but plots individual slopes visualizing the within-player variation in the slopes.

Ten<-ggplot(data = Data, aes(x = MAV, y = Ten, colour = factor(ID))) + 
  geom_point(size = 2, alpha = 0.75) +
  geom_smooth(method = "lm", se = FALSE, size = 0.5) +  
  scale_y_continuous(labels = scales::number_format(accuracy = 0.1)) +
  scale_color_viridis_d(option = "viridis", direction = 1)+
  theme_classic() +
  ylab("10-m time (s)") +
  xlab("Leap distance (cm)") +
 theme(text = element_text(size = 12, color = "black", family = "sans"), axis.text = element_text(size = 12, color = "black", family = "sans")) +
  guides(color = FALSE)

Twenty<-ggplot(data = Data, aes(x = MAV, y = Twenty, colour = factor(ID))) + 
  geom_point(size = 2, alpha = 0.75) +
  geom_smooth(method = "lm", se = FALSE, size = 0.5) +  
  scale_y_continuous(labels = scales::number_format(accuracy = 0.1)) +
  scale_color_viridis_d(option = "viridis", direction = 1)+
  theme_classic() +
  ylab("20-m time (s)") +
  xlab("Leap distance (cm)") +
 theme(text = element_text(size = 12, color = "black", family = "sans"), axis.text = element_text(size = 12, color = "black", family = "sans")) +
  guides(color = FALSE)


figure2_new <- ggarrange(Ten, Twenty,
                        labels = c("A", "B"),
                        ncol = 2, nrow = 1, common.legend = TRUE, legend = "bottom",
                        font.label = list(
                          family = "sans",  # Specify sans-serif font
                          size = 12  # Specify font size
                        ))
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
ggsave(
  "figure2_new.png", dpi = 640, 
)
Saving 7 x 5 in image
figure2_new

Current figures

Here is the code for “figure 3” through rmcorr for all and pre post PHV

sp<-rmcorr(participant = ID, measure1 = MAV, measure2 = Ten, dataset = Data)

mp<-rmcorr(participant = ID, measure1 = MAV, measure2 = Twenty, dataset = Data)

par(mfrow=c(1,2))
plot(sp, Data, overall = F, lty = 1.0, ylim = c(1.6, 2.2), xlab = "Stride (cm)", ylab = "10-m (s)")

plot(mp, Data, overall = F, lty = 1.0, ylim = c(1.6, 2.2), xlab = "Stride (cm)", ylab = "20-m (s)")

Preten <- rmcorr(participant = ID, measure1 = MAV, measure2 = Ten, dataset = PrePHV)

Pretwenty <- rmcorr(participant = ID, measure1 = MAV, measure2 = Twenty, dataset = PrePHV)

Postten <- rmcorr(participant = ID, measure1 = MAV, measure2 = Ten, dataset = Postphvnew)

Posttwenty <- rmcorr(participant = ID, measure1 = MAV, measure2 = Twenty, dataset = Postphvnew)

jpeg("figure3.jpg",  width = 4800, height = 4600, pointsize = 20,
     quality = 100, res = 320)


par(mfrow = c(2, 2), mar = c(2.5, 2.5, 2.5, 2.5)) # Adjust the "mar" values to increase margins


plot(Preten, overall = F, lty = 1.0, mgp=c(1.2,0.2,0),  tck = -0.02, family = "serif", xlab = "Leap distance (cm)", ylab = "10-m time (s)", frame.plot = FALSE, main="A")

plot(Pretwenty, overall = F, lty = 1.0, mgp=c(1.2,0.2,0),  tck = -0.02, family = "serif", xlab = "Leap distance (cm)", ylab = "20-m time (s)",frame.plot = FALSE, main="B")

plot(Postten, overall = F, lty = 1.0, mgp=c(1.2,0.2,0),  tck = -0.02, family = "serif", xlab = "Leap distance (cm)", ylab = "10-m time (s)", frame.plot = FALSE,main="C")

plot(Posttwenty, overall = F, lty = 1.0, mgp=c(1.2,0.2,0),  tck = -0.02, family = "serif", xlab = "Leap distance (cm)", ylab = "20-m time (s)",frame.plot = FALSE, main="D")

dev.off()
quartz_off_screen 
                2 
# Load package
par(mfrow = c(1, 1))

png("figure2.png", res = 640)

ggplot figure pre / post

This visualizes the same data but plots individual slopes visualizing the within-player variation in the slopes.

Preten <- ggplot(data = PrePHV, aes(x = MAV, y = Ten, colour = factor(ID))) + 
  geom_point(size = 2, alpha = 0.75) +
  geom_smooth(method = "lm", se = FALSE, size = 0.5) +  
  scale_y_continuous(labels = scales::number_format(accuracy = 0.1)) +
  scale_color_viridis_d(option = "viridis", direction = 1)+
  theme_classic() +
  ylab("10-m time (s)") +
  xlab("Leap distance (cm)") +
 theme(text = element_text(size = 12, color = "black", family = "sans"), axis.text = element_text(size = 12, color = "black", family = "sans")) +
  guides(color = FALSE)

Pretwenty <- ggplot(data = Postphvnew, aes(x = MAV, y = Twenty, colour = factor(ID))) + 
  geom_point(size = 2, alpha = 0.75) +
  geom_smooth(method = "lm", se = FALSE, size = 0.5) +  
  scale_y_continuous(labels = scales::number_format(accuracy = 0.1)) +
  scale_color_viridis_d(option = "viridis", direction = 1)+
  theme_classic() +
  ylab("20-m time (s)") +
  xlab("Leap distance (cm)") +
 theme(text = element_text(size = 12, color = "black", family = "sans"), axis.text = element_text(size = 12, color = "black", family = "sans")) +
  guides(color = FALSE)

Postten <- ggplot(data = Postphvnew, aes(x = MAV, y = Ten, colour = factor(ID))) + 
  geom_point(size = 2, alpha = 0.75) +
  geom_smooth(method = "lm", se = FALSE, size = 0.5) +  
  scale_y_continuous(labels = scales::number_format(accuracy = 0.1)) +
  scale_color_viridis_d(option = "viridis", direction = 1)+
  theme_classic() +
  ylab("10-m time (s)") +
  xlab("Leap distance (cm)") +
 theme(text = element_text(size = 12, color = "black", family = "sans"), axis.text = element_text(size = 12, color = "black", family = "sans")) +
  guides(color = FALSE)


Posttwenty <- ggplot(data = Postphvnew, aes(x = MAV, y = Twenty, colour = factor(ID))) +
  geom_point(size = 2, alpha = 0.75) +
  geom_smooth(method = "lm", se = FALSE, size = 0.5) +  
  scale_y_continuous(labels = scales::number_format(accuracy = 0.1)) +
  scale_color_viridis_d(option = "viridis", direction = 1)+
  theme_classic() +
  ylab("20-m time (s)") +
  xlab("Leap distance (cm)") +
 theme(text = element_text(size = 12, color = "black", family = "sans"), axis.text = element_text(size = 12, color = "black", family = "sans")) +
  guides(color = FALSE)

figure3_new <- ggarrange(Preten , Pretwenty, Postten, Posttwenty,
                        labels = c("A", "B", "C", "D"),
                        ncol = 2, nrow = 2, common.legend = TRUE, legend = "bottom",
                        font.label = list(
                          family = "sans",  # Specify sans-serif font
                          size = 12  # Specify font size
                        ))
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
ggsave(
  "figure3_new.png", dpi = 640, 
)
Saving 7 x 5 in image
figure3_new