library(ggplot2) # your daily visualization package
library(ggthemes) # your daily theme for visualization
library(ggrepel) 

Introduction

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.

Data Input

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.

Data pre-processing

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 :

  • change type of data; ROLE and SPECIALLY from chr into factor.
  • remove columns; 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 ...

Contents of Columns

  • HERO: hero
  • MV_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 power
  • MGC_DFN: magic defense/resistance
  • MANA: mana, a resource needed to cast spells.
  • HP_RGN: HP regenerate rate
  • BA_CC: basic attack crit. Chance
  • P_ATK: physical attack
  • P_DFN: physical defense
  • HP: Hit Point (Indicate health on hero)
  • ATK_SPD: attack speed
  • MANA_RGN: mana regenerate rate
  • SKILL_CC: skill crit. chance
  • ROLE: 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.

Missing Data

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.

Data Processing and Visualization

In this section, we will analyze each status.

HP

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;

  • Hero who rolled as FIGHTER and TANK has the highest HP of all role, but hero who rolled as a Tank has highest mean of HP than hero who rolled as Fighter.
  • There’s an outlier on Tank and most of hero who rolled as TANK has the highest HP, but there is a hero who rolled as Tank has lowest HP as SUPPORT hero.
  • Hero who rolled as SUPPORT has the lowest mean of HP of all role.

2. Mean of HP

hp_role <- aggregate(HP ~ ROLE, data = mobalog, FUN = mean)
hp_role$HP <- round(hp_role$HP)
hp_role
ggplot(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;

  • The highest mean of HP was held by hero who rolled as TANK.
  • The lowest mean of HP was held by hero who rolled as SUPPORT.
  • Most of hero who rolled as Tank have HP more than 2700.
  • Hero who rolled as MAGE slightly, even almost have same value as hero who rolled as SUPPORT.

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;

  • Hylos has the highest HP of all Hero on Mobile Legend with HP 3300.
  • Gap between Hylos and Tigreal are huge, afterwards the difference is slightly ramps.
  • Uranus has the lowest HP of all Tank Hero. We could indicate Uranus’s HP were between 2700 to 2500.

Physical Attack

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;

  • There’s no outlier detected on hero who rolled as MARKSMAN and SUPPORT, thus there is no hero has physical attack point exceeding or vice versa for each hero that rolled as Marksman and Support.
  • Marksman hero has biggest distribution than other hero.
  • Highest mean Physical Attack point held by hero who rolled as FIGHTER. On the second placed by ASSASIN hero and the third placed by MARKSMAN.
  • Average hero who rolled as MAGE has physical attack point lower than other hero, but there is at least 1 Mage hero has highest physical attack point than other Mage hero.

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;

  • In fact, Grock, hero who rolled as Tank, has the highest Physical Attack point than predicted hero (whether hero who rolled as Marksman or Fighter). There is higher chance to win if we or one of team member choose Grock.
  • The difference of physical attack point between hero are slightly ramps, all of 10 hero above has physical attack point more than 120.
  • The amount of Marksman hero and Fighter hero is same, there are 4 Marksman and Fighter hero that has highest physical attack point than each role category. Lesley has highest physical attack point of all Marksman hero, and Aldous has highest physical attack point of all Fighter hero.

Physical defense

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;

  • Highest physical defense point were nominated by FIGHTER and TANK hero.
  • The difference of physical defense are slightly ramps for each rank.

Correlation Between HP Regeneration and Physical Defense

HP 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;

  • Average hero has low HP Regeneration, but high at Physical Defense.
  • Most of Fighter hero has high Physical Defense point and Movement Speed, but low at HP Regeneration.
  • Most of Mage hero has small Physical Defense, HP Regeneration, and Movement Speed. But there is one hero who has higher HP Regeneration and Movement Speed, but low at Physical Defense.
  • Most of Tank hero has small HP Regeneration, but high at Physical Defense. There is one hero that has high Movement Speed and HP Regeneration, but pretty low at Physical Defense.

Conclusion

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.