library(ggplot2)
library(fmsb)
library(dplyr)
df<-read.csv('starcraft.csv',sep=',')
df <- na.omit(df)
df<-df[df$TotalHours!=1000000,]
The radarchart will show the average of some features ; a summary of the data (summary(df)
) shows that we can group (better visualization for a radarchart) some features :
As a first try I selected only players in the GrandMaster League :
l7<-(filter(df,LeagueIndex==7)) %>% select(Age, HoursPerWeek, TotalHours, APM, ActionLatency, GapBetweenPACs, ActionsInPAC) %>% summarise(avg_age = mean(Age), avg_Hours = mean(HoursPerWeek), avgTotalHours = mean(TotalHours), avg_APM = mean(APM), avg_actionLatency = mean(ActionLatency), avg_GapPacs= mean(GapBetweenPACs), avg_actionPac = mean(ActionsInPAC))
print(l7)
## avg_age avg_Hours avgTotalHours avg_APM avg_actionLatency avg_GapPacs
## 1 21.17143 31.71429 1581.029 189.5557 40.3429 22.97816
## avg_actionPac
## 1 5.226089
We then need to define 2 vectors containing the min and max of each features. I then (for now) by hand :
max<-c(50,50,1750,200,100,100,10)
min<-c(0,0,0,0,0,0)
The next step is to build a dataframe where the first row is the max vector, the second row is the min vector and the last one is your data :
ldata7<-rbind(max,min,l7)
r7<-(filter(df,LeagueIndex==7)) %>% select(SelectByHotkeys,AssignToHotkeys,UniqueHotkeys,MinimapAttacks, MinimapRightClicks,NumberOfPACs, TotalMapExplored, WorkersMade, UniqueUnitsMade, ComplexUnitsMade, ComplexAbilityUsed) %>% summarise(avg_selectHotKeys = mean(SelectByHotkeys), avg_assignHotKeys = mean(AssignToHotkeys), avg_uniqueHotKeys = mean(UniqueHotkeys), avg_minimapAttacks = mean(MinimapAttacks),avg_minimapRightClicks = mean(MinimapRightClicks), avg_numPacs = mean(NumberOfPACs), avg_mapExplored = mean(TotalMapExplored), avg_worker = mean(WorkersMade), avg_uniqueUnits = mean(UniqueUnitsMade), avg_complexUnit = mean(ComplexUnitsMade), avg_complexAbility = mean(ComplexAbilityUsed))
maxR<-c(.01,.01,.01,.01,.01,.01,.01,.01,.01,.01,.01)
minR<-c(0,0,0,0,0,0,0,0,0,0,0)
rdata7<-rbind(maxR,minR,r7)
print(r7)
## avg_selectHotKeys avg_assignHotKeys avg_uniqueHotKeys avg_minimapAttacks
## 1 0.009418354 0.0007233996 7.979106e-05 0.0003404847
## avg_minimapRightClicks avg_numPacs avg_mapExplored avg_worker
## 1 0.0005703949 0.005111202 0.0003129981 0.001238312
## avg_uniqueUnits avg_complexUnit avg_complexAbility
## 1 7.916403e-05 8.178046e-05 0.0002672946
Then display the radarchart, using some custom fonts (example taken from this blog)
op <- par(mar=c(1, 2, 2, 1),mfrow=c(1, 2))
radarchart( ldata7 , axistype=2 ,
#custom polygon
pcol=rgb(0.2,0.5,0.5,0.9) , pfcol=rgb(0.2,0.5,0.5,0.5) , plwd=4 ,
#custom the grid
cglcol="grey", cglty=1, axislabcol="grey", caxislabels=seq(0,2000,5), cglwd=0.8,
#custom labels
vlcex=0.8
)
radarchart( rdata7 , axistype=2 ,
#custom polygon
pcol=rgb(0.2,0.5,0.5,0.9) , pfcol=rgb(0.2,0.5,0.5,0.5) , plwd=4 ,
#custom the grid
cglcol="grey", cglty=1, axislabcol="grey", caxislabels=seq(0,.1,5), cglwd=0.8,
#custom labels
vlcex=0.8
)
par(op)
Players in higher league (Master, Grand Master) have :
compared to players in minor leagues (Bronze)
As an example between profiles of a GrandMaster league and a bronze league :
comparisonL<-rbind(max,min,l1,l7)
comparisonR<-rbind(maxR,minR,r1,r7)
op <- par(mar=c(1, 2, 2, 1),mfrow=c(1, 2))
radarchart( comparisonL )
radarchart( comparisonR )
par(op)