This is an Rmarkdown file which will produces a custom map based on the Leaflet package, which will mark-up all places where the Final of League of Legend World Championship has occurred since 2011 to 2018. (yes, I am a big fan, and I am fully enjoying the freedom of this assignment). Instead of using a fancy League of Legend logo mark-up, each location will be represented by a circle, which size depends on Prize Pot / Viewers (all information based on Wikipedia).
Clicking on the mark-up will give you the year of the championship, and will produce an url which will redirect the user to the Wiki page.
The code is presented in the Appendix section to keep the paper clean.
Please note: Clusters have not been added in order to better reflect the gradual increase in the price/views over the years.
Note: the radius has been scaled up by x5.
Note: no scaling done on the radius.
Below is the detailed data used for this plot.
| Prize (in million $) | Nb of Viewer (in million) | Location | City | Country | Latitude | Longitude | Prize Color | Viewer Color | |
|---|---|---|---|---|---|---|---|---|---|
| 2011 | 0.100 | 1.6 | DreamHack | Hägersten | Sweden | 59.29834 | 17.99664 | #FF0000 | #A020F0 |
| 2012 | 2.000 | 8.0 | University of Southern California | LA | USA | 34.02235 | -118.28512 | #DA2400 | #AD33CD |
| 2013 | 2.050 | 32.0 | STAPLES Center | LA | USA | 34.04345 | -118.26634 | #B64800 | #BB46AB |
| 2014 | 2.130 | 27.0 | Seoul World Cup Stadium | Seoul | Korea | 37.55582 | 126.91033 | #916D00 | #C85989 |
| 2015 | 2.130 | 36.0 | Mercedes-Benz Arena | Berlin | Germany | 52.50572 | 13.44321 | #6D9100 | #D66C66 |
| 2016 | 5.070 | 26.0 | STAPLES Center | LA | USA | 34.04000 | -118.26000 | #48B600 | #E37E44 |
| 2017 | 4.597 | 60.0 | Beijing National Stadium | Beijing | China | 39.98722 | 116.38824 | #24DA00 | #F19222 |
| 2018 | 6.700 | 99.6 | Incheon Munhak Stadium | Incheon | Korea | 37.43583 | 126.69175 | #00FF00 | #FFA500 |
# Loading libraries
library(leaflet)
library(knitr)
# Defining color gradient to reflect the evolution of each variable
colPrice <- colorRampPalette(c("red", "green"))
colView <- colorRampPalette(c("purple", "orange"))
# Defining the base dataframe which contains:
# Prize Pot, Number of viewer per year, Latitude, Longitude, Colors to be used for showing
# Price and Viewer
worldChampionShip = data.frame(price = c(0.1, 2, 2.05, 2.13, 2.13, 5.07, 4.597, 6.7),
viewer = c(1.6, 8, 32, 27, 36, 26, 60, 99.6),
loc = c("DreamHack", "University of Southern California",
"STAPLES Center", "Seoul World Cup Stadium",
"Mercedes-Benz Arena", "STAPLES Center",
"Beijing National Stadium", "Incheon Munhak Stadium"),
city = c("Hägersten", "LA", "LA", "Seoul", "Berlin", "LA",
"Beijing", "Incheon"),
ctry = c("Sweden", "USA", "USA", "Korea", "Germany", "USA",
"China", "Korea"),
lat = c(59.298340, 34.022350, 34.043450, 37.555823, 52.505718,
34.04, 39.987222, 37.435825),
lng = c(17.996639, -118.285118, -118.266340, 126.910326, 13.443210,
-118.26, 116.388242, 126.691747),
colPrice = colPrice(8),
colView = colView(8)
)
# Defining the URL to appear in the pop-up. We will add later other information
urlList = c(
"<a href='https://en.wikipedia.org/wiki/League_of_Legends_World_Championship#Season_1'>
2011: DreamHack</a>",
"<a href='https://en.wikipedia.org/wiki/League_of_Legends:_Season_2_World_Championship'>
2012: University of Southern California</a>",
"<a href='https://en.wikipedia.org/wiki/League_of_Legends:_Season_3_World_Championship'>
2013: STAPLES Center</a>",
"<a href='https://en.wikipedia.org/wiki/2014_League_of_Legends_World_Championship'>
2014: Seoul World Cup Stadium</a>",
"<a href='https://en.wikipedia.org/wiki/2015_League_of_Legends_World_Championship'>
2015: Mercedes-Benz Arena</a>",
"<a href='https://en.wikipedia.org/wiki/2016_League_of_Legends_World_Championship'>
2016: STAPLES Center</a>",
"<a href='https://en.wikipedia.org/wiki/2017_League_of_Legends_World_Championship'>
2017: Beijing National Stadium</a>",
"<a href='https://en.wikipedia.org/wiki/2018_League_of_Legends_World_Championship'>
2018: Incheon Munhak Stadium</a>"
)
# Defining Legend Labels
series = c("Season 1", "Season 2", "Season 3", "Season 4", "Season 5", "Season 6", "Season 7", "Season 8")
# Defining the final text to print in the pop-up (this will show price)
myPopup = paste(urlList, "<br>",
"Price:", worldChampionShip$price, "million USD")
# Display maps with custom Circle, custom Base Map, custom Legend and Custom center
worldChampionShip %>%
leaflet() %>%
addTiles() %>%
addCircleMarkers(weight = 3, radius = worldChampionShip$price*10,
popup = myPopup, color = worldChampionShip$colPrice) %>%
addLegend(labels = series, colors = worldChampionShip$colPrice) %>%
addProviderTiles(providers$Esri.WorldImagery) %>%
setView(30, 10, zoom = 1.25)
# Defining the final text to print in the pop-up (this will show number of viewer)
myPopup = paste(urlList, "<br>",
"Views:", worldChampionShip$viewer, "million")
# Display maps with custom Circle, custom Base Map, custom Legend and Custom center
worldChampionShip %>%
leaflet() %>%
addTiles() %>%
addCircleMarkers(weight = 3, radius = worldChampionShip$viewer,
popup = myPopup, color = worldChampionShip$colView) %>%
addLegend(labels = series, colors = worldChampionShip$colView) %>%
addProviderTiles(providers$Esri.WorldImagery) %>%
setView(50, 10, zoom = 1.25)
# Changing the column names and row names to make it presentable
colnames(worldChampionShip) = c("Prize (in million $)", "Nb of Viewer (in million)","Location",
"City","Country", "Latitude", "Longitude", "Prize Color",
"Viewer Color")
rownames(worldChampionShip) = 2011:2018
# Display the dataframe in a fancy table
kable(worldChampionShip, caption = "League of Legends World Championship Finals", align = rep("c", 9))