這是我的第一個(gè)數(shù)據(jù)小項(xiàng)目化焕,(期中考試陸陸續(xù)續(xù)寫(xiě)了一點(diǎn),不過(guò)都跟猴子搬玉米似的惕稻,第二次繼續(xù)寫(xiě)又不連貫了险绘,所以考完在圖書(shū)館蹲了一天總算是把它shut down了 :))那啥,如果有做的不好的地方還請(qǐng)各位見(jiàn)諒坛善,畢竟新手,哈哈。
因?yàn)樵氖窃趉aggle上寫(xiě)的,用的英文吗蚌,就暫時(shí)不翻譯過(guò)來(lái)了(對(duì)了,數(shù)據(jù)來(lái)自于kaggle數(shù)據(jù)集 League of Legends.有關(guān)于數(shù)據(jù)集的介紹就不贅述了纯出。
分割線
- Hello everyone, this is a data analysis demo of League Of Legends (LOL) competitions. As an 5 years old LOLer I appreciate the pleasure that this game bring us so much. And this is the reason why I choose LOL as my first project.
- Therefore, I try my best to use what I have learned to complete in this demo, although it seems not good QAQ,cause I'm a rookie. So if there are some problems in my demo. Plaese give me some comments or guidences,thanks! (PS: RNG fighting in MSI ! :)
Then I will display it from 5 aspects:
- Bans
- Number of leagues
- Gamelength
- Kills
- Monsters and structures
Bans
library(tidyverse)
library(RColorBrewer)
library(dplyr)
library(grid)
library(gridExtra)
options(warn = -1)
bans <- read.csv("../input/bans.csv")
head(bans)
- reshape the data
bans <- bans[,-1]
newbans <- bans %>% tbl_df() %>% gather(.,ban_1,ban_2,ban_3,ban_4,ban_5,key = "ban_num",value = "heros") %>% filter(.,heros != "")
head(newbans)
- visualization
ggplot(newbans,aes(x=heros,fill=heros))+geom_histogram(stat = "count",binwidth = 20)+coord_flip()+theme(legend.position = "none")+
facet_wrap(facets = ~Team,scales = "free")
we can get some info from this picture.
- Leblanc,shen,Syndra are most banned heroes in blue Team.
- Leblanc,Kalista,Zac are most banned heroes in red Team
Numeber of games per League of Legends
leagues <- read.csv("../input/LeagueofLegends.csv")
test <- leagues %>% select(.,League,Year,Season) %>% filter(League == c("MSI","NALCS","LMS","LCK","EULCS")) %>%
group_by(League,Year) %>% summarise(number = n())
m <- c(RColorBrewer::brewer.pal(12,"Set3"),brewer.pal(3,"Set2"))
z1 <- ggplot(test,aes(x=Year,y = number,fill=League))+geom_histogram(stat = "identity",position = "stack")+
scale_fill_manual(values = m)+theme(legend.position = "none")
z2 <- ggplot(test,aes(x=reorder(League,-number),y = number,fill=League))+geom_bar(stat = "identity")+scale_fill_manual(values = m)+
labs(x="League",y="Number of Competitions")+theme(legend.position = "top",legend.text = element_text(size = 5))
grid.arrange(z1,z2,ncol=2)
Eh~ In this part, I only choose 5 main Leagues from the data, and I wonder why this data doesn't have LPL competitons? Maybe our country's walls. So we can get some info that LCK league has most competition and NALCS second. But if LPL in data , I think it may have more competitions than NALCS
newleagues <- mutate(leagues,seatype = str_c(leagues$Season,leagues$Type))
newleagues %>% group_by(League,Year,seatype) %>% summarise(number=n()) %>% ggplot(aes(Year,y = League,size = number,color =seatype))+
geom_point()+facet_wrap(~seatype)+theme(legend.position = "top",axis.text.y = element_text(size = 8),legend.text=element_text(size=5),legend.key.size = unit(.2, "cm"))
Compare gamelength in different leagues
p <- leagues %>% select(League,gamelength) %>% filter(League == c("MSI","NALCS","LMS","LCK","EULCS"))
ggplot(p,aes(x = gamelength,colour = League))+geom_density()
ggplot(p,aes(x = gamelength,fill=League))+geom_density()+facet_wrap(~League)
ggplot(p,aes(x = League,y = gamelength,fill = League))+geom_boxplot()
- we can find that diffrenet leagues' gamelength distributions are similar in general. Most games length end in 30 ~40 min, but there are some interesting phenomenons. For example: MSI gamelength has a rise during 50~60 min .Besides, LCK and NALCS have longest game in total and MSI has most short gamelength.( ps: I'm curious about why NALCS have similar gamelength with LCK, cause in my previous cognition,NALCS always has fast pace of the game 0_0 )
Kills
kills <- read.csv("../input/kills.csv")
#choose my favorite players from the data
players <- c("Faker","Doublelift","Uzi","Rekkles","PraY")
kills %>% mutate(Player = word(kills$Kille,-1)) %>% select(Time,Player) %>% filter(Player %in% players) %>%
ggplot(aes(x =Time,fill= Player))+geom_density(alpha = 0.7)+facet_wrap(~Player,nrow = 5)
I choose 4 ADCs in 2018 MSI League.(PraY,Rekkles,Uzi,Doublelift) and a so famous person in LOL -faker,then I found almost players start to get Kills from 15 minutes . Before this time, they farmed in themselves' line. And 20~30 min become a most bellicose time to most teams.
Monsters and Structures
monsters <- read.csv("../input/monsters.csv")
monsters %>% ggplot(aes(x = Type,y =Time,fill=Type))+geom_violin()+coord_flip()+
theme(legend.position = "top",legend.text = element_text(size=8))
dragon_name <- c("AIR_DRAGON","EARTH_DRAGON","FIRE_DRAGON","WATER_DRAGON")
p1 <- monsters %>% filter(Type == dragon_name) %>% ggplot(aes(x = Type,fill=Type))+geom_histogram(stat = "count")+scale_fill_brewer(4,"Set3")+
theme(legend.position = "top")
p2 <- monsters %>% filter(Type != dragon_name) %>% ggplot(aes(x = Type,fill=Type))+geom_histogram(stat = "count")+scale_fill_brewer(3,"Set3")+
theme(legend.position="top")+coord_flip()
grid.arrange(p1,p2)
- The picture tell us that amount of 4 diffrent element dragons are equal(alright~, I admit that AIR_DRAGON amount seems a little lack than others )
- Besides we can also find that FIRE_DRAGON is most popular dragon in teams. And a strange point is that most ELDER_DRAGON was killed when it borns or minutes later.
structures <- read.csv("../input/structures.csv")
structures %>% na.omit() %>% mutate(NewTeam = str_sub(Team,1,1)) %>%
ggplot(aes(Time,colour = NewTeam))+geom_density()+facet_wrap(~Type)+scale_color_manual(values = c("blue","red"),labels = c("blue","red"),name = "Team")+labs(title = "The time distribution of different teams destroy structures")
- Don’t you find some special point in the line chart?--yes! Blue win rate seems that more than red especially in 20~35 min and it shows similar phenomenon on other towers.
something I want to say ...
- At last ,thanks anyway if you read my whole analysis project. If my poor English expression ability or worst code writting method give you some uncomfortable experience, please tell us , I'm so glad to change these bad points.
- Finally,I get some sparks and refers from the kernel Jonathan Bouchet LOL games : 4 years of esport,thanks so much!