Transferring an analytical technique from ecology to the sport sciences
Sports Medicine
Carl T. Woods1*, Sam Robertson2, Neil French Collier3, Anne L. Swinbourne4, Anthony S. Leicht1
1Discipline of Sport and Exercise Science, James Cook University, Queensland, Australia
2Institute of Sport, Exercise & Activity Living (ISEAL), Victoria University, Melbourne, Australia
2Faculty of Sustainability, Leuphana University Luneburg, Germany
3Psychology, James Cook University, Queensland, Australia
*Corresponding Author
Carl Woods, Discipline of Sport and Exercise Science, James Cook University, Townsville, Queensland, Australia
Ph: +61 07 4781 6550 Mob: +61 421254329 Email:
Supplementary Material
Example 2.1 R code:
######## Set work directory ########
setwd("F:/Publications/Learng transfer")
AFL <-read.csv("AFL_Brownlow.csv")
str(AFL)
##### Melt data #####
library(ggplot2)
library(reshape2)
library(dplyr)
library(ggthemes)
AFLMelt <- melt(AFL, id=c("season", "player"), variable.name="Metric", value.name="Value")
str(AFLMelt)
#### Multivariate plotting using nMDS #####
library(vegan)
##### Create a subset of the data containing only the metrics #####
d <- AFL[ ,3:15]
dist <- metaMDS(d)
dist$points
plot(dist$points, pch=19, cex=0.75)
dhull <- as.data.frame(dist$points)
dhull$season <- factor(AFL$season)
##### Plot the dissimilarity matrix ######
ggplot(data=dhull, aes(x=MDS1, y=MDS2, group=1)) +
geom_point(size=3) + geom_point(aes(color=season), size=3) +
geom_segment(aes(xend=c(tail(MDS1, n=-1), NA), yend=c(tail(MDS2, n=-1), NA)),
arrow=arrow(length=unit(0.4,"cm")), size=0.4)+
geom_path(size=0.45)+
theme_tufte()
ggsave("Figure_2.pdf", width=10, height=6, dpi=150)
######################################################################################
Example 2.2 R code:
######## Set work directory ########
setwd("F:/Publications/Learng transfer")
NRL <-read.csv("NRL_Stat.csv")
str(NRL)
##### Melt data #####
library(ggplot2)
library(reshape2)
library(dplyr)
library(ggthemes)
NRLMelt <- melt(NRL6, id=c("club", "Qaurtile"), variable.name="Metric", value.name="Value")
str(NRLMelt)
#### Multivariate plotting using nMDS #####
library(vegan)
##### Create a subset of the data containing only the metrics #####
d <- NRL[ ,3:15]
dist <- metaMDS(d)
dist$points
plot(dist$points, pch=19, cex=0.75)
dhull <- as.data.frame(dist$points)
dhull$club <- factor(NRL4$club)
dhull$Ladder <- factor(NRL4$Quartile)
chulls <- ddply(dhull, .(Quartile),
function(df) df[chull(df$MDS1, df$MDS2), ])
##### Plot the dissimilarity matrix ######
ggplot(data=dhull, aes(x=MDS1, y=MDS2, group=1, label = club)) +
geom_label(size = 3.5, aes(fill = Quartile), color="white", fontface="bold") +
geom_segment(aes(xend=c(tail(MDS1, n=-1), NA), yend=c(tail(MDS2, n=-1), NA)),
arrow=arrow(length=unit(0.1,"cm")), size=0.1)+
geom_path(size=0.35)+
theme_tufte()
ggsave("Figure_3.pdf", width=10, height=6, dpi=150)
##################################################################################
Example 2.3 R code:
######## Set work directory ########
setwd("F:/Publications/Learning transfer")
Bball <-read.csv("BballEvo.csv")
str(Bball)
##### Melt data #####
library(ggplot2)
library(reshape2)
library(dplyr)
library(ggthemes)
BballMelt <- melt(Bball, id=c("Olympics"), variable.name="Metric", value.name="Value")
str(BballMelt)
#### Multivariate plotting using nMDS #####
library(vegan)
##### Create a subset of the data containing only the metrics #####
d <- Bball[ ,3:12]
dist <- metaMDS(d)
dist$points
plot(dist$points, pch=19, cex=0.75)
dhull <- as.data.frame(dist$points)
dhull$season <- factor(Bball$Olympics)
chulls <- ddply(dhull, .(Olympics),
function(df) df[chull(df$MDS1, df$MDS2), ])
##### Plot the dissimilarity matrix ######
ggplot(data=dhull, aes(x=MDS1, y=MDS2)) +
geom_polygon(data=chulls, aes(x=MDS1, y=MDS2, fill=Olympics), alpha=0.1) +
geom_point(data=dhull, aes(color=Olympics), size = 2) +
theme(panel.background=element_blank())
ggsave("Figure_4.pdf", width=10, height=6, dpi=150)
1