You can pick 1 of 6 classes:
To answer that, I created an interactive polychart.js graphic with "dat.gui" (angularJS) controls built in.
My second question was to answer what "clothing sets" are the most popular in the top leaderboard.
Clothing gives certain attributes to increase player stats.
To answer this, I looked at the most frequent sets per class. I wanted to look at the top 1000 and top 100 to see differences.
I'll use the "nv.d3" javascript library to plot each class and the most frequent sets used.
Get the names of top 1000 players from the most current leaderboard from the Diablo 3 API.
top1000<-fromJSON(paste0("https://us.api.battle.net/data/d3/season/6/leaderboard/achievement-points?access_token=",SARAKEY))
## Rank HeroBattleTag HeroId HeroClass ## 1 1 Knightmare#1642 50291904 demon hunter ## 2 2 Cursewords#1359 75503053 demon hunter ## 3 3 wby#1325 75508223 demon hunter ## 4 4 Blacksheep#1512 75438396 demon hunter ## 5 5 Beldox#1259 75506076 wizard ## 6 6 Tarzimal#1145 75510116 demon hunter
## Rank HeroBattleTag HeroId HeroClass ## 1 1 Knightmare#1642 50291904 demon hunter ## 2 2 Cursewords#1359 75503053 demon hunter ## 3 3 wby#1325 75508223 demon hunter ## 4 4 Blacksheep#1512 75438396 demon hunter ## 5 5 Beldox#1259 75506076 wizard ## 6 6 Tarzimal#1145 75510116 demon hunter
Get data of the top 1000 players from a different data source on the same API.
I had to create unique urls for each user and their "hero" number...
heroItemURL <- lapply(1:1000, function(i) { paste0("https://us.api.battle.net/d3/profile/", results$HeroBattleTag[i], "/hero/", results$HeroId[i], "?locale=en_US&apikey=", key) })
And then use that URL to create 1000 queries to the Battle.Net API
heroItems<-lapply(1:1000, function(i) { fromJSON(heroItemURL[[i]]) })
"https://us.api.battle.net/d3/profile/流星追月#3113/hero/69485497?locale=en_US&apikey=SARAKEY"
Those URLs did not render in R, but they somehow fixed themselves and were able to correctly get back the data.
Cleaning
Here's an example:
setItems<- lapply(1:1000, function(i) { (heroItems[[i]]["items"][[1]][1][[1]]["setItemsEquipped"][[1]]) })
Here's an example of a function I wrote called "setClean".
This loops through the 6 classes to pull out the most frequent sets for each class.
setClean<-function(x){ as.data.frame(xtabs(~ setName + class , x))[!as.data.frame(xtabs(~ setName + class , x))$Freq==0, ] } classSets1000<-setClean(heroSetDataFinal) #all 1000 top players classSets100<-setClean(filter(heroSetDataFinal, (rank%in%(1:100)))) #only the top 100 ranked players head(classSets1000)
Creating graphs to answer my questions
I used the rCharts package to create the interactive visualizations
sets1000Plot <- nPlot( Freq ~ class, group = "setName", data = classSets1000, type= "multiBarChart" )
Publishing my results
To solve this, I embedded the graphs with HTML iFrames.
Jekyll is a static site generator that integrates with github. You can create and publish jekyll blogs to your github from RStudio using Yihui's Knitr Jekyll repo.
Plot my results onto a website for people to view on github.
Thanks! Questions?