library(ggplot2) # your daily visualization package
library(ggthemes) # your daily theme for visualization
library(ggrepel) knitr::include_graphics("mlbb.jpg")Who doesn’t know Mobile Legends? This game published at 2016 has a lot of fan and player, even championship held in everywhere. This LBB aims to fulfill classwork on Data Visualization (DV) and will show some EDA and Visualization on MLBB Data.
The very first step to do is read the data and assign it on mobalog.
mobalog <- read.csv("df_ml_story.csv")
head(mobalog)Then, we need to inspect the data
dim(mobalog)## [1] 83 15
So, there are 83 heros on MLBB and 15 columns that 14 of it represent strength and status of each heros.
Then, we need to know is the data type of each column are correct.
str(mobalog)## 'data.frame': 83 obs. of 15 variables:
## $ HERO : chr "Miya" "Balmond" "Saber" "Alice" ...
## $ MV_SPD : int 240 260 260 240 250 260 260 260 260 260 ...
## $ MGC_PWR : int 0 0 0 0 0 0 0 0 0 0 ...
## $ MGC_DFN : int 10 10 10 10 10 10 10 10 10 10 ...
## $ MANA : int 445 0 443 493 510 450 0 431 422 440 ...
## $ HP_RGN : int 30 47 35 36 34 42 39 29 42 46 ...
## $ BA_CC : int 0 0 0 0 0 0 0 0 0 0 ...
## $ P_ATK : int 129 119 118 114 115 112 123 121 115 116 ...
## $ P_DFN : int 17 25 17 21 17 25 21 20 24 25 ...
## $ HP : int 2524 2836 2599 2573 2501 2890 2821 2633 2769 2709 ...
## $ ATK_SPD : num 0.85 0.85 0.87 0.8 0.864 0.826 0.9 0.9 0.85 0.826 ...
## $ MANA_RGN : int 15 0 16 18 18 12 0 16 12 10 ...
## $ SKILL_CC : int 0 0 0 0 0 0 0 0 0 0 ...
## $ ROLE : chr "MM" "FT" "ASS" "MG" ...
## $ SPECIALLY: chr "Reap" "Charge" "Charge" "Charge" ...
There are some data type that we need to change. Before change the type of the data, let’s inspect some of column further. If we take a glimpse, it seems like there are some column that has same content.
unique(mobalog$MGC_PWR)## [1] 0
unique(mobalog$MGC_DFN)## [1] 10
unique(mobalog$BA_CC)## [1] 0
unique(mobalog$SKILL_CC)## [1] 0
These columns should be remove because they only have one value on the contents. Then, we need to :
ROLE and SPECIALLY from chr into factor.MGC_PWR, MGC_DFN, BA_CC, and SKILL_CC.# remove column
mobalog <- subset(x = mobalog,
select = -c(MGC_PWR, MGC_DFN, BA_CC, SKILL_CC))
# change data type
mobalog$ROLE <- as.factor(mobalog$ROLE)
mobalog$SPECIALLY <- as.factor(mobalog$SPECIALLY)
# check data
str(mobalog)## 'data.frame': 83 obs. of 11 variables:
## $ HERO : chr "Miya" "Balmond" "Saber" "Alice" ...
## $ MV_SPD : int 240 260 260 240 250 260 260 260 260 260 ...
## $ MANA : int 445 0 443 493 510 450 0 431 422 440 ...
## $ HP_RGN : int 30 47 35 36 34 42 39 29 42 46 ...
## $ P_ATK : int 129 119 118 114 115 112 123 121 115 116 ...
## $ P_DFN : int 17 25 17 21 17 25 21 20 24 25 ...
## $ HP : int 2524 2836 2599 2573 2501 2890 2821 2633 2769 2709 ...
## $ ATK_SPD : num 0.85 0.85 0.87 0.8 0.864 0.826 0.9 0.9 0.85 0.826 ...
## $ MANA_RGN : int 15 0 16 18 18 12 0 16 12 10 ...
## $ ROLE : Factor w/ 6 levels "ASS","FT","MG",..: 4 2 1 3 5 6 2 1 6 6 ...
## $ SPECIALLY: Factor w/ 10 levels "Burst","Charge",..: 9 2 2 2 7 3 2 2 6 6 ...
HERO: heroMV_SPD: movement speed; enhances the Hero’s ability to chase and escape enemies, rotate around the map and objectives, and dodge skills.MGC_POWER: magic powerMGC_DFN: magic defense/resistanceMANA: mana, a resource needed to cast spells.HP_RGN: HP regenerate rateBA_CC: basic attack crit. ChanceP_ATK: physical attackP_DFN: physical defenseHP: Hit Point (Indicate health on hero)ATK_SPD: attack speedMANA_RGN: mana regenerate rateSKILL_CC: skill crit. chanceROLE: hero’s role, there are ASS = Assassin, FT = Fighter, MG = Mage, MM = Marksmen, SP = Support, TK = Tank.SPECIALLY: hero’s specialty, there are Burst, Charge, Crowd Control, Damage, Initiator, Poke, Push, Reap, Regen.Alright, all done. Then, we need to check is there any missing data or not.
colSums(is.na(mobalog))## HERO MV_SPD MANA HP_RGN P_ATK P_DFN HP ATK_SPD
## 0 0 0 0 0 0 0 0
## MANA_RGN ROLE SPECIALLY
## 0 0 0
Nice. Then, we could start processing on the data.
In this section, we will analyze each status.
We will analyze hero who has highest HP point of all hero. Why HP? Because HP is an important aspect when we’re playing game.
1. Which hero has the highest HP by Role?
ggplot(mobalog,
aes(ROLE, HP)) +
geom_boxplot(aes(fill = ROLE)) +
geom_hline(yintercept = mean(mobalog$HP), col = "darkblue") +
labs(title = "HP by Hero's Role",
subtitle = "Distribution of HP on Hero") +
theme(plot.background = element_rect(fill = "white"),
panel.background = element_rect(fill = "white"))Graph above shows that;
2. Mean of HP
hp_role <- aggregate(HP ~ ROLE, data = mobalog, FUN = mean)
hp_role$HP <- round(hp_role$HP)
hp_roleggplot(hp_role, aes(reorder(ROLE, -HP),
HP,
fill = HP)) +
geom_col() +
labs(title = "Mean of HP",
subtitle = "by Role of Hero",
x = "ROLE") +
theme(panel.background = element_rect(fill = "white"))Bar chart above shows;
3. Which Tank Hero?
Let’s subset hero who rolled as tank
# choose Tank hero only
tank <- mobalog[mobalog$ROLE == "TK", ]
nrow(tank)## [1] 12
There are 12 hero who rolled as TANK, which one has the highest HP?
ggplot(tank, aes(reorder(HERO, -HP),
HP,
fill = HP))+
geom_col() +
labs(title = "Highest HP of Tank Hero",
subtitle = "Hero who has highest HP of all Tank Hero",
x = "HERO") +
theme(panel.background = element_rect(fill = "white"))Bar chart above shows;
1. Which hero has the biggest damage when attack?
ggplot(mobalog,
aes(ROLE, P_ATK)) +
geom_boxplot(aes(fill = ROLE)) +
geom_hline(yintercept = mean(mobalog$P_ATK), col = "darkblue") +
labs(title = "Physical Attack by Hero's Role",
subtitle = "Distribution of Physical Attack on Hero",
y = "Physical Attack") +
theme(plot.background = element_rect(fill = "white"),
panel.background = element_rect(fill = "white"))Box plot above shows that;
2. Who has more damage when attack the enemy?
# arrange the data by `P_ATK` and subset it to 10 hero only
patk <- head(mobalog[ order(mobalog$P_ATK, decreasing = T), ],10)
# visualize it!
ggplot(patk,
aes(reorder(HERO,-P_ATK), P_ATK)) +
geom_col(aes(fill = ROLE)) +
geom_label_repel(patk,
mapping = aes(label = P_ATK),
size = 3) +
labs(title = "Top 10 Hero by Physical Attack",
subtitle = "10 Hero who has biggest physical attack point",
x = "Hero",
y = "Physical Attack Point") +
theme(panel.background = element_rect(fill = "white"))Bar chart above shows that;
We have analyze HP and Physical Attack, now let’s analyze the Physical defense where physical defense is one of several factor that made hero survive on game.
# arrange and subset 10 hero who has highest point of physical defense
pdef <- head(mobalog[order(mobalog$P_DFN, decreasing = T), ],10)
# visualize it!
ggplot(pdef,
aes(reorder(HERO,-P_DFN), P_DFN)) +
geom_col(aes(fill = ROLE)) +
geom_label_repel(pdef,
mapping = aes(label = P_DFN),
size = 3) +
labs(title = "Top 10 Hero by Physical Defense",
subtitle = "10 Hero who has biggest physical defense point",
x = "Hero",
y = "Physical Defense Point") +
theme(panel.background = element_rect(fill = "white"))Bar chart above shows that;
HP Regeneration and Physical DefenseHP Regeneration and Physical Defense are two aspect to obscure when our HP drained because of enemy’s attack. Thus, we will analyze is there any correlation between HP Regeneration and Physical Defense.
ggplot(mobalog, aes(HP_RGN, P_DFN)) +
geom_point(aes(size = MV_SPD,
col = ROLE),
alpha = 0.5) +
geom_smooth() +
labs(title = "Correlation between HP Regeneration and Physical Defense",
x = "HP Regeneration",
y = "Physical Defense",
size = "Movement Speed") +
theme(panel.background = element_rect(fill = "white"))## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
Graph above shows;
From all graph above, we can conclude that;
Tank hero has highest HP point than other hero, and Hylos records highest HP point of all hero with 3300 HP.
Marksman hero has biggest distribution of Physical Attack point than other hero. But the first rank who held highest Physical Attack point were Grock, which rolled as Tank. For Marksman hero, Lesley held highest Physical Attack point. Aldous held highest Physical Attack point for Fighter hero. Meanwhile on the 10th rank, Fanny held highest Physical Attack point for Assasin hero.
Highest Physical Defense point were dominated and 50:50 by Tank hero and Fighter hero. On the first rank were held by Johnson for Tank hero, and Balmond placed first rank for Fighter hero.
There is correlation between HP Regeneration and Physical Defense.
In the end, when we playing a game with team, teamwork is the most important variable to have higher chance to win the game.