## PULL THE ACTIVITY METRICS
athlete = GC.athlete()
mmp <- GC.season.meanmax()
mmpduration<-c(5,60,300,2500)
mmpdata1 <- mmp$wpk[mmpduration]
## MANIPULATE THE DATA
ifelse (athlete$gender=='male', worldclass<-c(24,11.5,7.6,6.4), worldclass<-c(19.4,9.3,6.6,5.9))
ifelse (athlete$gender=='male', index.BOT<-c(4.2,4.9,3.1,2.9), index.BOT<-c(4.3,5.0,2.9,2.5))
mmpdata2 <-(((10*mmpdata1/worldclass-index.BOT)/(10-index.BOT))*10)
## Calculate the percentiles
mmpdata2 <- ifelse(mmpdata2<0,NA,mmpdata2) ## Remove Negative Values
## Athlete Phenotype
allroundertolerance = 1.2
best = which(mmpdata2==max(mmpdata2))
if (max(mmpdata2)-min(mmpdata2)<allroundertolerance) {
phenotype="All-Rounder"
} else if (best==3) {
phenotype<-"Puncheur"
} else if (best==4) {
phenotype<-"TT'er"
} else
phenotype<-"Sprinter"
## PLOT THE CHART
## Chart Inputs & Settings
lbls1<-c("5s","1m","5m","FTP")
axislabels<-c("Untrained","Cat 5","Cat 4","Cat 3","Cat 2","Cat 1","Domestic Pro","World Tour","")
ylbl = "W/Kg"
chartsub = "Power Duration"
chartlbl = paste0("Cyclist Power Profile - ", athlete$name)
textsize=1
col1="Red"
col2="White"
indices<-c(0,1.4,2.5,3.7,4.9,6.1,7.3,8.4)
## Chart Sizing
GC.page(width=800, height=600)
## BarPlot
barplot(mmpdata2,xlim=c(0,4.8),ylim=c(0,11),main=chartlbl,cex.main=1.5,font.main=2,sub=chartsub,font.xlab=2,col=heat.colors(7),names.arg=lbls1,yaxt='n',border=TRUE,space=0.2,col.axis=col2,col.sub=col2)
## Reference Lines
abline(h=indices,slope=0,col="white",lty=3)
text(0.42, indices+(0.2), axislabels, cex=textsize, col=col2)
## Bar Value Labels
vlab<-c(1,2.25,3.4,4.6)
ylab<-c(mmpdata2-0.2)
text(vlab, ylab, round(mmpdata1,digits=2), col="black", cex=textsize)
## Summary Box Labels
summary1 = paste0("Gender: ", athlete$gender)
summary2 = paste0("Weight: ", athlete$weight, "kg")
summary3 = paste0("Phenotype: ", phenotype)
textscale = 0.8
text(4,10,summary1,cex=textsize*textscale,col=col1)
text(4,9.5,summary2,cex=textsize*textscale,col=col1)
text(4,9,summary3,cex=textsize*textscale,col=col1)