League of Legends 数据分析小项目

image.png

这是我的第一个数据小项目,(期中考试陆陆续续写了一点,不过都跟猴子搬玉米似的,第二次继续写又不连贯了,所以考完在图书馆蹲了一天总算是把它shut down了 :))那啥,如果有做的不好的地方还请各位见谅,毕竟新手,哈哈。
因为原文是在kaggle上写的,用的英文,就暂时不翻译过来了(对了,数据来自于kaggle数据集 League of Legends.有关于数据集的介绍就不赘述了。


image.png

分割线


  • 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)
image.png
  • 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)
image.png
  • 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")
Rplot01.jpeg

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)

image.png

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"))
image.png

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()
image.png
ggplot(p,aes(x = gamelength,fill=League))+geom_density()+facet_wrap(~League)
image.png
ggplot(p,aes(x = League,y = gamelength,fill = League))+geom_boxplot()
image.png
  • 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)
image.png

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))
image.png
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)
image.png
  • 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")
image.png
  • 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!
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,125评论 6 498
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,293评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,054评论 0 351
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,077评论 1 291
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,096评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,062评论 1 295
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,988评论 3 417
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,817评论 0 273
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,266评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,486评论 2 331
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,646评论 1 347
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,375评论 5 342
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,974评论 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,621评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,796评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,642评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,538评论 2 352

推荐阅读更多精彩内容