The first step we are going to take is to load the libraries to prepare the data.

library(knitr)
library(readxl)
library(readr)
library(dplyr)
## 
## Adjuntando el paquete: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)

Let’s import the data and save it in two variables.

data_games <- read_excel("D:/UPV/2º/Proyecto II/league_data.xlsx")
View(data_games)
summary(data_games)
##     game_id          game_start_utc                   game_duration 
##  Min.   :3.552e+09   Min.   :2024-02-17 16:03:00.00   Min.   : 101  
##  1st Qu.:3.727e+09   1st Qu.:2025-01-14 22:39:00.00   1st Qu.:1277  
##  Median :3.729e+09   Median :2025-01-17 22:44:00.00   Median :1618  
##  Mean   :3.726e+09   Mean   :2025-01-11 21:39:50.10   Mean   :1582  
##  3rd Qu.:3.729e+09   3rd Qu.:2025-01-19 08:19:00.00   3rd Qu.:1883  
##  Max.   :3.730e+09   Max.   :2025-01-20 21:16:00.00   Max.   :3307  
##                                                                     
##   game_mode          game_type         game_version           map_id     
##  Length:40410       Length:40410       Length:40410       Min.   :11.00  
##  Class :character   Class :character   Class :character   1st Qu.:11.00  
##  Mode  :character   Mode  :character   Mode  :character   Median :11.00  
##                                                           Mean   :11.24  
##                                                           3rd Qu.:11.00  
##                                                           Max.   :12.00  
##                                                                          
##  platform_id           queue_id   participant_id      puuid          
##  Length:40410       Min.   :400   Min.   : 1.000   Length:40410      
##  Class :character   1st Qu.:420   1st Qu.: 3.000   Class :character  
##  Mode  :character   Median :420   Median : 5.000   Mode  :character  
##                     Mean   :430   Mean   : 5.498                     
##                     3rd Qu.:450   3rd Qu.: 8.000                     
##                     Max.   :890   Max.   :10.000                     
##                                                                      
##  summoner_name      summoner_id        summoner_level    champion_id   
##  Length:40410       Length:40410       Min.   :   2.0   Min.   :  1.0  
##  Class :character   Class :character   1st Qu.: 201.0   1st Qu.: 45.0  
##  Mode  :character   Mode  :character   Median : 360.0   Median : 99.0  
##                                        Mean   : 393.3   Mean   :176.8  
##                                        3rd Qu.: 544.0   3rd Qu.:203.0  
##                                        Max.   :2065.0   Max.   :950.0  
##                                                                        
##  champion_name         team_id       win          individual_position
##  Length:40410       Min.   :100   Mode :logical   Length:40410       
##  Class :character   1st Qu.:100   FALSE:20190     Class :character   
##  Mode  :character   Median :100   TRUE :20220     Mode  :character   
##                     Mean   :150                                      
##                     3rd Qu.:200                                      
##                     Max.   :200                                      
##                                                                      
##  team_position          lane               role               kills       
##  Length:40410       Length:40410       Length:40410       Min.   : 0.000  
##  Class :character   Class :character   Class :character   1st Qu.: 3.000  
##  Mode  :character   Mode  :character   Mode  :character   Median : 6.000  
##                                                           Mean   : 7.274  
##                                                           3rd Qu.:10.000  
##                                                           Max.   :48.000  
##                                                                           
##      deaths          assists       baron_kills       dragon_kills   
##  Min.   : 0.000   Min.   : 0.00   Min.   :0.00000   Min.   :0.0000  
##  1st Qu.: 4.000   1st Qu.: 5.00   1st Qu.:0.00000   1st Qu.:0.0000  
##  Median : 7.000   Median : 9.00   Median :0.00000   Median :0.0000  
##  Mean   : 7.289   Mean   :12.37   Mean   :0.05266   Mean   :0.2931  
##  3rd Qu.:10.000   3rd Qu.:17.00   3rd Qu.:0.00000   3rd Qu.:0.0000  
##  Max.   :36.000   Max.   :78.00   Max.   :3.00000   Max.   :6.0000  
##                                                                     
##   gold_earned      gold_spent    total_damage_dealt  
##  Min.   :  500   Min.   :    0   Min.   :-2.147e+09  
##  1st Qu.: 9123   1st Qu.: 8325   1st Qu.: 5.510e+04  
##  Median :11764   Median :10850   Median : 1.095e+05  
##  Mean   :11826   Mean   :10899   Mean   : 6.992e+04  
##  3rd Qu.:14411   3rd Qu.:13400   3rd Qu.: 1.720e+05  
##  Max.   :36211   Max.   :50950   Max.   : 6.998e+05  
##                                                      
##  total_damage_dealt_to_champions physical_damage_dealt_to_champions
##  Min.   :     0                  Min.   :     0                    
##  1st Qu.: 13000                  1st Qu.:  1267                    
##  Median : 21355                  Median :  5505                    
##  Mean   : 23864                  Mean   : 11096                    
##  3rd Qu.: 31569                  3rd Qu.: 17685                    
##  Max.   :194173                  Max.   :184418                    
##                                                                    
##  magic_damage_dealt_to_champions true_damage_dealt_to_champions
##  Min.   :     0                  Min.   :    0                 
##  1st Qu.:  1463                  1st Qu.:  217                 
##  Median :  6444                  Median :  826                 
##  Mean   : 11258                  Mean   : 1510                 
##  3rd Qu.: 17384                  3rd Qu.: 1860                 
##  Max.   :128404                  Max.   :32724                 
##                                                                
##  damage_dealt_to_objectives damage_dealt_to_turrets total_damage_taken
##  Min.   :     0             Min.   :    0           Min.   :     0    
##  1st Qu.:  1344             1st Qu.:  455           1st Qu.: 18617    
##  Median :  4668             Median : 1808           Median : 26652    
##  Mean   : 10196             Mean   : 2909           Mean   : 29187    
##  3rd Qu.: 13497             3rd Qu.: 4175           3rd Qu.: 36910    
##  Max.   :108370             Max.   :29001           Max.   :266336    
##                                                                       
##  physical_damage_taken magic_damage_taken true_damage_taken time_ccing_others
##  Min.   :     0        Min.   :     0     Min.   :    0     Min.   :  0.00   
##  1st Qu.:  8982        1st Qu.:  6237     1st Qu.:  491     1st Qu.: 11.00   
##  Median : 13963        Median : 10274     Median : 1029     Median : 23.00   
##  Mean   : 15793        Mean   : 11822     Mean   : 1571     Mean   : 28.69   
##  3rd Qu.: 20673        3rd Qu.: 15571     3rd Qu.: 1964     3rd Qu.: 39.00   
##  Max.   :160227        Max.   :101393     Max.   :35558     Max.   :366.00   
##                                                                              
##   vision_score    wards_placed    wards_killed   vision_wards_bought_in_game
##  Min.   :  0.0   Min.   : 0.00   Min.   : 0.00   Min.   : 0.000             
##  1st Qu.:  0.0   1st Qu.: 0.00   1st Qu.: 0.00   1st Qu.: 0.000             
##  Median : 14.0   Median : 7.00   Median : 1.00   Median : 0.000             
##  Mean   : 18.4   Mean   : 8.17   Mean   : 1.85   Mean   : 0.914             
##  3rd Qu.: 24.0   3rd Qu.:11.00   3rd Qu.: 3.00   3rd Qu.: 1.000             
##  Max.   :193.0   Max.   :99.00   Max.   :36.00   Max.   :35.000             
##                                                                             
##      item0            item1            item2            item3       
##  Min.   :     0   Min.   :     0   Min.   :     0   Min.   :     0  
##  1st Qu.:  3006   1st Qu.:  3033   1st Qu.:  3020   1st Qu.:  3009  
##  Median :  3115   Median :  3115   Median :  3100   Median :  3085  
##  Mean   :  4644   Mean   :  4295   Mean   :  3994   Mean   :  3781  
##  3rd Qu.:  3876   3rd Qu.:  4005   3rd Qu.:  3179   3rd Qu.:  3211  
##  Max.   :328020   Max.   :326657   Max.   :328020   Max.   :326621  
##                                                                     
##      item4            item5            item6       solo_tier        
##  Min.   :     0   Min.   :     0   Min.   :   0   Length:40410      
##  1st Qu.:  1036   1st Qu.:     0   1st Qu.:3340   Class :character  
##  Median :  3036   Median :  1038   Median :3340   Mode  :character  
##  Mean   :  3155   Mean   :  1947   Mean   :2901                     
##  3rd Qu.:  3145   3rd Qu.:  3072   3rd Qu.:3364                     
##  Max.   :328020   Max.   :328020   Max.   :3513                     
##                                                                     
##   solo_rank            solo_lp          solo_wins       solo_losses    
##  Length:40410       Min.   :   0.00   Min.   :  0.00   Min.   :  0.00  
##  Class :character   1st Qu.:  21.00   1st Qu.:  9.00   1st Qu.:  8.00  
##  Mode  :character   Median :  47.50   Median : 18.00   Median : 16.00  
##                     Mean   :  63.31   Mean   : 22.14   Mean   : 20.47  
##                     3rd Qu.:  77.00   3rd Qu.: 31.00   3rd Qu.: 28.00  
##                     Max.   :1215.00   Max.   :130.00   Max.   :138.00  
##                     NA's   :12544     NA's   :12544    NA's   :12544   
##   flex_tier          flex_rank            flex_lp         flex_wins     
##  Length:40410       Length:40410       Min.   :  0.00   Min.   : 0.000  
##  Class :character   Class :character   1st Qu.: 22.00   1st Qu.: 4.000  
##  Mode  :character   Mode  :character   Median : 47.00   Median : 7.000  
##                                        Mean   : 47.88   Mean   : 8.665  
##                                        3rd Qu.: 73.00   3rd Qu.:11.000  
##                                        Max.   :553.00   Max.   :93.000  
##                                        NA's   :30047    NA's   :30047   
##   flex_losses     champion_mastery_level champion_mastery_points
##  Min.   : 0.000   Min.   :   1.00        Min.   :       0       
##  1st Qu.: 4.000   1st Qu.:   4.00        1st Qu.:   16790       
##  Median : 6.000   Median :   7.00        Median :   49140       
##  Mean   : 7.926   Mean   :  18.07        Mean   :  189645       
##  3rd Qu.:10.000   3rd Qu.:  15.00        3rd Qu.:  160671       
##  Max.   :80.000   Max.   :1278.00        Max.   :15501091       
##  NA's   :30047    NA's   :30             NA's   :30             
##  champion_mastery_lastPlayTime champion_mastery_lastPlayTime_utc
##  Min.   :1.503e+12             Min.   :2017-08-14 03:46:00.0    
##  1st Qu.:1.737e+12             1st Qu.:2025-01-16 20:47:00.0    
##  Median :1.737e+12             Median :2025-01-18 22:51:00.0    
##  Mean   :1.737e+12             Mean   :2025-01-13 18:21:28.7    
##  3rd Qu.:1.737e+12             3rd Qu.:2025-01-19 20:39:00.0    
##  Max.   :1.737e+12             Max.   :2025-01-20 23:54:00.0    
##  NA's   :30                    NA's   :30                       
##  champion_mastery_pointsSinceLastLevel champion_mastery_pointsUntilNextLevel
##  Min.   :      0                       Min.   :-1466491                     
##  1st Qu.:   2573                       1st Qu.:  -10034                     
##  Median :   6140                       Median :    2213                     
##  Mean   :  22489                       Mean   :  -12939                     
##  3rd Qu.:  21006                       3rd Qu.:    5753                     
##  Max.   :1477491                       Max.   :   23985                     
##  NA's   :30                            NA's   :30                           
##  champion_mastery_tokensEarned final_abilityHaste final_abilityPower
##  Min.   : 0.000                Min.   :0          Min.   :   0.0    
##  1st Qu.: 0.000                1st Qu.:0          1st Qu.:   0.0    
##  Median : 1.000                Median :0          Median :  30.0    
##  Mean   : 1.929                Mean   :0          Mean   : 146.3    
##  3rd Qu.: 2.000                3rd Qu.:0          3rd Qu.: 259.0    
##  Max.   :29.000                Max.   :0          Max.   :1675.0    
##  NA's   :30                                                         
##   final_armor    final_armorPen final_armorPenPercent final_attackDamage
##  Min.   : 18.0   Min.   :0      Min.   : 0.000        Min.   : 47.0     
##  1st Qu.: 86.0   1st Qu.:0      1st Qu.: 0.000        1st Qu.:100.0     
##  Median :103.0   Median :0      Median : 0.000        Median :134.0     
##  Mean   :119.9   Mean   :0      Mean   : 4.159        Mean   :189.3     
##  3rd Qu.:141.0   3rd Qu.:0      3rd Qu.: 0.000        3rd Qu.:270.0     
##  Max.   :869.0   Max.   :0      Max.   :61.000        Max.   :994.0     
##                                                                         
##  final_attackSpeed final_bonusArmorPenPercent final_bonusMagicPenPercent
##  Min.   :  60.0    Min.   : 0.00000           Min.   :0                 
##  1st Qu.: 132.0    1st Qu.: 0.00000           1st Qu.:0                 
##  Median : 149.0    Median : 0.00000           Median :0                 
##  Mean   : 168.7    Mean   : 0.00495           Mean   :0                 
##  3rd Qu.: 192.0    3rd Qu.: 0.00000           3rd Qu.:0                 
##  Max.   :1231.0    Max.   :50.00000           Max.   :0                 
##                                                                         
##  final_ccReduction final_cooldownReduction  final_health   final_healthMax
##  Min.   : 0.000    Min.   :0               Min.   :    0   Min.   :  540  
##  1st Qu.: 0.000    1st Qu.:0               1st Qu.:    0   1st Qu.: 2228  
##  Median : 0.000    Median :0               Median : 1118   Median : 2602  
##  Mean   : 6.793    Mean   :0               Mean   : 1282   Mean   : 2804  
##  3rd Qu.: 7.000    3rd Qu.:0               3rd Qu.: 2221   3rd Qu.: 3138  
##  Max.   :73.000    Max.   :0               Max.   :12216   Max.   :12514  
##                                                                           
##  final_healthRegen final_lifesteal   final_magicPen   final_magicPenPercent
##  Min.   :   0.00   Min.   :  0.000   Min.   : 0.000   Min.   : 0.000       
##  1st Qu.:  26.00   1st Qu.:  0.000   1st Qu.: 0.000   1st Qu.: 0.000       
##  Median :  33.00   Median :  0.000   Median : 0.000   Median : 0.000       
##  Mean   :  76.17   Mean   :  2.563   Mean   : 5.654   Mean   : 1.926       
##  3rd Qu.:  45.00   3rd Qu.:  3.000   3rd Qu.:12.000   3rd Qu.: 0.000       
##  Max.   :7936.00   Max.   :100.000   Max.   :49.000   Max.   :48.000       
##                                                                            
##  final_magicResist final_movementSpeed final_omnivamp    final_physicalVamp
##  Min.   : -3.00    Min.   : 129.0      Min.   : 0.0000   Min.   :0         
##  1st Qu.: 48.00    1st Qu.: 380.0      1st Qu.: 0.0000   1st Qu.:0         
##  Median : 54.00    Median : 395.0      Median : 0.0000   Median :0         
##  Mean   : 71.65    Mean   : 405.4      Mean   : 0.0437   Mean   :0         
##  3rd Qu.: 81.00    3rd Qu.: 415.0      3rd Qu.: 0.0000   3rd Qu.:0         
##  Max.   :515.00    Max.   :1193.0      Max.   :25.0000   Max.   :0         
##                                                                            
##   final_power    final_powerMax  final_powerRegen  final_spellVamp    
##  Min.   :    0   Min.   :    0   Min.   :   0.00   Min.   : 0.000000  
##  1st Qu.:  496   1st Qu.:  783   1st Qu.:  30.00   1st Qu.: 0.000000  
##  Median :  845   Median : 1038   Median :  41.00   Median : 0.000000  
##  Mean   : 1024   Mean   : 1258   Mean   :  61.02   Mean   : 0.005593  
##  3rd Qu.: 1257   3rd Qu.: 1570   3rd Qu.:  67.00   3rd Qu.: 0.000000  
##  Max.   :10000   Max.   :10000   Max.   :1013.00   Max.   :26.000000  
## 
data_champions <- read.csv("D:/UPV/2º/Proyecto II/200125_LoL_champion_data.csv")
View(data_champions)
summary(data_champions)
##       X                   id           apiname             title          
##  Length:172         Min.   :  1.00   Length:172         Length:172        
##  Class :character   1st Qu.: 43.75   Class :character   Class :character  
##  Mode  :character   Median :102.50   Mode  :character   Mode  :character  
##                     Mean   :195.73                                        
##                     3rd Qu.:233.25                                        
##                     Max.   :950.00                                        
##    difficulty      herotype           alttype            resource        
##  Min.   :1.000   Length:172         Length:172         Length:172        
##  1st Qu.:1.000   Class :character   Class :character   Class :character  
##  Median :2.000   Mode  :character   Mode  :character   Mode  :character  
##  Mean   :1.866                                                           
##  3rd Qu.:2.000                                                           
##  Max.   :3.000                                                           
##     stats            rangetype             date              patch          
##  Length:172         Length:172         Length:172         Length:172        
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##    changes              role           client_positions   external_positions
##  Length:172         Length:172         Length:172         Length:172        
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##      damage        toughness        control         mobility    
##  Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   :1.000  
##  1st Qu.:2.000   1st Qu.:1.000   1st Qu.:1.000   1st Qu.:1.000  
##  Median :3.000   Median :1.000   Median :2.000   Median :2.000  
##  Mean   :2.465   Mean   :1.616   Mean   :1.994   Mean   :1.791  
##  3rd Qu.:3.000   3rd Qu.:2.000   3rd Qu.:3.000   3rd Qu.:2.000  
##  Max.   :3.000   Max.   :3.000   Max.   :3.000   Max.   :3.000  
##     utility          style        adaptivetype             be      
##  Min.   :0.000   Min.   :  0.00   Length:172         Min.   : 450  
##  1st Qu.:1.000   1st Qu.: 30.00   Class :character   1st Qu.:1350  
##  Median :1.000   Median : 65.00   Mode  :character   Median :3150  
##  Mean   :1.453   Mean   : 59.69                      Mean   :3230  
##  3rd Qu.:2.000   3rd Qu.: 90.00                      3rd Qu.:4800  
##  Max.   :3.000   Max.   :100.00                      Max.   :7800  
##        rp          skill_i            skill_q            skill_w         
##  Min.   :260.0   Length:172         Length:172         Length:172        
##  1st Qu.:585.0   Class :character   Class :character   Class :character  
##  Median :790.0   Mode  :character   Mode  :character   Mode  :character  
##  Mean   :711.8                                                           
##  3rd Qu.:880.0                                                           
##  Max.   :975.0                                                           
##    skill_e            skill_r             skills            fullname        
##  Length:172         Length:172         Length:172         Length:172        
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##    nickname        
##  Length:172        
##  Class :character  
##  Mode  :character  
##                    
##                    
## 

We need to rename the column ‘apiname’ to ‘champion_name’ and then join the variables.

colnames(data_champions)[colnames(data_champions) == 'apiname'] <- 'champion_name'

Special case: repeated champion (Kled). This champion is repeated in the champion dataset because he can have two forms during the match. However, in the match dataset, his two forms are not differentiated. Therefore, we will stick with his primary form for the project.

data_champions <- data_champions[data_champions$X!="Kled", ]

We join both datasets, using the variable champion_name.

df_merged <- merge(data_champions,data_games,by= "champion_name")
View(df_merged)

We eliminated variables that we considered unusable for the analysis of this data. In addition, we eliminated identifiers, which are practically useless and are considered players’ personal information.

eliminar <- c("X", "id", "title", "patch", "changes",
              "role.x", "be", "rp", "skill_i", "skill_q",
              "skill_w", "skill_e", "skill_r", "skills", "fullname",
              "nickname", "game_type", "map_id", "queue_id", "champion_id",
              "individual_position", "lane", "role.y", "vision_wards_bought_in_game",
              "item0", "item1", "item2", "item3", "item4", "item5", "item6",
              "solo_lp", "flex_lp", "champion_mastery_lastPlayTime",
              "champion_mastery_lastPlayTime_utc", "champion_mastery_pointsSinceLastLevel",
              "champion_mastery_pointsUntilNextLevel", "champion_mastery_tokensEarned",
              "final_health", "final_power", "date")

ids <- c("game_id", "platform_id", "participant_id", "puuid",
         "summoner_name", "summoner_id", "team_id", "game_start_utc")

df_selected <- df_merged[, !names(df_merged) %in% eliminar]
df_selected <- df_selected[, !names(df_selected) %in% ids]

View(df_selected)
summary(df_selected)
##  champion_name        difficulty      herotype           alttype         
##  Length:40242       Min.   :1.000   Length:40242       Length:40242      
##  Class :character   1st Qu.:1.000   Class :character   Class :character  
##  Mode  :character   Median :2.000   Mode  :character   Mode  :character  
##                     Mean   :1.807                                        
##                     3rd Qu.:2.000                                        
##                     Max.   :3.000                                        
##                                                                          
##    resource            stats            rangetype         client_positions  
##  Length:40242       Length:40242       Length:40242       Length:40242      
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##  external_positions     damage        toughness        control     
##  Length:40242       Min.   :1.000   Min.   :1.000   Min.   :1.000  
##  Class :character   1st Qu.:2.000   1st Qu.:1.000   1st Qu.:1.000  
##  Mode  :character   Median :3.000   Median :1.000   Median :2.000  
##                     Mean   :2.496   Mean   :1.549   Mean   :1.968  
##                     3rd Qu.:3.000   3rd Qu.:2.000   3rd Qu.:2.000  
##                     Max.   :3.000   Max.   :3.000   Max.   :3.000  
##                                                                    
##     mobility        utility          style        adaptivetype      
##  Min.   :1.000   Min.   :0.000   Min.   :  0.00   Length:40242      
##  1st Qu.:1.000   1st Qu.:1.000   1st Qu.: 30.00   Class :character  
##  Median :2.000   Median :1.000   Median : 65.00   Mode  :character  
##  Mean   :1.743   Mean   :1.436   Mean   : 58.14                     
##  3rd Qu.:2.000   3rd Qu.:2.000   3rd Qu.: 90.00                     
##  Max.   :3.000   Max.   :3.000   Max.   :100.00                     
##                                                                     
##  game_duration   game_mode         game_version       summoner_level  
##  Min.   : 101   Length:40242       Length:40242       Min.   :   2.0  
##  1st Qu.:1278   Class :character   Class :character   1st Qu.: 201.0  
##  Median :1618   Mode  :character   Mode  :character   Median : 360.0  
##  Mean   :1582                                         Mean   : 393.4  
##  3rd Qu.:1883                                         3rd Qu.: 544.0  
##  Max.   :3307                                         Max.   :2065.0  
##                                                                       
##     win          team_position          kills            deaths      
##  Mode :logical   Length:40242       Min.   : 0.000   Min.   : 0.000  
##  FALSE:20109     Class :character   1st Qu.: 3.000   1st Qu.: 4.000  
##  TRUE :20133     Mode  :character   Median : 6.000   Median : 7.000  
##                                     Mean   : 7.272   Mean   : 7.282  
##                                     3rd Qu.:10.000   3rd Qu.:10.000  
##                                     Max.   :48.000   Max.   :36.000  
##                                                                      
##     assists       baron_kills       dragon_kills     gold_earned   
##  Min.   : 0.00   Min.   :0.00000   Min.   :0.0000   Min.   :  500  
##  1st Qu.: 5.00   1st Qu.:0.00000   1st Qu.:0.0000   1st Qu.: 9120  
##  Median : 9.00   Median :0.00000   Median :0.0000   Median :11762  
##  Mean   :12.35   Mean   :0.05236   Mean   :0.2918   Mean   :11823  
##  3rd Qu.:17.00   3rd Qu.:0.00000   3rd Qu.:0.0000   3rd Qu.:14410  
##  Max.   :78.00   Max.   :3.00000   Max.   :6.0000   Max.   :36211  
##                                                                    
##    gold_spent    total_damage_dealt   total_damage_dealt_to_champions
##  Min.   :    0   Min.   :-2.147e+09   Min.   :     0                 
##  1st Qu.: 8325   1st Qu.: 5.509e+04   1st Qu.: 12983                 
##  Median :10850   Median : 1.096e+05   Median : 21334                 
##  Mean   :10897   Mean   : 6.965e+04   Mean   : 23849                 
##  3rd Qu.:13400   3rd Qu.: 1.718e+05   3rd Qu.: 31561                 
##  Max.   :50950   Max.   : 6.998e+05   Max.   :194173                 
##                                                                      
##  physical_damage_dealt_to_champions magic_damage_dealt_to_champions
##  Min.   :     0                     Min.   :     0                 
##  1st Qu.:  1284                     1st Qu.:  1450                 
##  Median :  5600                     Median :  6377                 
##  Mean   : 11140                     Mean   : 11198                 
##  3rd Qu.: 17750                     3rd Qu.: 17266                 
##  Max.   :184418                     Max.   :128404                 
##                                                                    
##  true_damage_dealt_to_champions damage_dealt_to_objectives
##  Min.   :    0                  Min.   :     0            
##  1st Qu.:  216                  1st Qu.:  1349            
##  Median :  824                  Median :  4672            
##  Mean   : 1510                  Mean   : 10189            
##  3rd Qu.: 1860                  3rd Qu.: 13480            
##  Max.   :32724                  Max.   :108370            
##                                                           
##  damage_dealt_to_turrets total_damage_taken physical_damage_taken
##  Min.   :    0           Min.   :     0     Min.   :     0       
##  1st Qu.:  457           1st Qu.: 18581     1st Qu.:  8974       
##  Median : 1819           Median : 26621     Median : 13938       
##  Mean   : 2917           Mean   : 29161     Mean   : 15779       
##  3rd Qu.: 4191           3rd Qu.: 36859     3rd Qu.: 20645       
##  Max.   :29001           Max.   :266336     Max.   :160227       
##                                                                  
##  magic_damage_taken true_damage_taken time_ccing_others  vision_score   
##  Min.   :     0     Min.   :    0     Min.   :  0.00    Min.   :  0.00  
##  1st Qu.:  6226     1st Qu.:  490     1st Qu.: 11.00    1st Qu.:  0.00  
##  Median : 10260     Median : 1028     Median : 23.00    Median : 14.00  
##  Mean   : 11810     Mean   : 1571     Mean   : 28.55    Mean   : 18.36  
##  3rd Qu.: 15554     3rd Qu.: 1964     3rd Qu.: 39.00    3rd Qu.: 23.00  
##  Max.   :101393     Max.   :35558     Max.   :366.00    Max.   :193.00  
##                                                                         
##   wards_placed     wards_killed     solo_tier          solo_rank        
##  Min.   : 0.000   Min.   : 0.000   Length:40242       Length:40242      
##  1st Qu.: 0.000   1st Qu.: 0.000   Class :character   Class :character  
##  Median : 7.000   Median : 1.000   Mode  :character   Mode  :character  
##  Mean   : 8.196   Mean   : 1.849                                        
##  3rd Qu.:11.000   3rd Qu.: 3.000                                        
##  Max.   :99.000   Max.   :36.000                                        
##                                                                         
##    solo_wins       solo_losses      flex_tier          flex_rank        
##  Min.   :  0.00   Min.   :  0.00   Length:40242       Length:40242      
##  1st Qu.:  9.00   1st Qu.:  8.00   Class :character   Class :character  
##  Median : 18.00   Median : 16.00   Mode  :character   Mode  :character  
##  Mean   : 22.14   Mean   : 20.47                                        
##  3rd Qu.: 31.00   3rd Qu.: 28.00                                        
##  Max.   :130.00   Max.   :138.00                                        
##  NA's   :12480    NA's   :12480                                         
##    flex_wins      flex_losses    champion_mastery_level champion_mastery_points
##  Min.   : 0.00   Min.   : 0.00   Min.   :   1.00        Min.   :       0       
##  1st Qu.: 4.00   1st Qu.: 4.00   1st Qu.:   4.00        1st Qu.:   16843       
##  Median : 7.00   Median : 6.00   Median :   7.00        Median :   49174       
##  Mean   : 8.67   Mean   : 7.93   Mean   :  18.06        Mean   :  189470       
##  3rd Qu.:11.00   3rd Qu.:10.00   3rd Qu.:  15.00        3rd Qu.:  160691       
##  Max.   :93.00   Max.   :80.00   Max.   :1278.00        Max.   :15501091       
##  NA's   :29920   NA's   :29920   NA's   :30             NA's   :30             
##  final_abilityHaste final_abilityPower  final_armor    final_armorPen
##  Min.   :0          Min.   :   0.0     Min.   : 18.0   Min.   :0     
##  1st Qu.:0          1st Qu.:   0.0     1st Qu.: 86.0   1st Qu.:0     
##  Median :0          Median :  30.0     Median :103.0   Median :0     
##  Mean   :0          Mean   : 145.4     Mean   :119.9   Mean   :0     
##  3rd Qu.:0          3rd Qu.: 257.0     3rd Qu.:141.0   3rd Qu.:0     
##  Max.   :0          Max.   :1675.0     Max.   :869.0   Max.   :0     
##                                                                      
##  final_armorPenPercent final_attackDamage final_attackSpeed
##  Min.   : 0.000        Min.   : 47.0      Min.   :  60.0   
##  1st Qu.: 0.000        1st Qu.:100.0      1st Qu.: 132.0   
##  Median : 0.000        Median :135.0      Median : 149.0   
##  Mean   : 4.176        Mean   :189.7      Mean   : 168.9   
##  3rd Qu.: 0.000        3rd Qu.:270.0      3rd Qu.: 193.0   
##  Max.   :61.000        Max.   :994.0      Max.   :1231.0   
##                                                            
##  final_bonusArmorPenPercent final_bonusMagicPenPercent final_ccReduction
##  Min.   : 0.00000           Min.   :0                  Min.   : 0.000   
##  1st Qu.: 0.00000           1st Qu.:0                  1st Qu.: 0.000   
##  Median : 0.00000           Median :0                  Median : 0.000   
##  Mean   : 0.00497           Mean   :0                  Mean   : 6.816   
##  3rd Qu.: 0.00000           3rd Qu.:0                  3rd Qu.: 7.000   
##  Max.   :50.00000           Max.   :0                  Max.   :73.000   
##                                                                         
##  final_cooldownReduction final_healthMax final_healthRegen final_lifesteal  
##  Min.   :0               Min.   :  540   Min.   :   0.00   Min.   :  0.000  
##  1st Qu.:0               1st Qu.: 2228   1st Qu.:  26.00   1st Qu.:  0.000  
##  Median :0               Median : 2601   Median :  33.00   Median :  0.000  
##  Mean   :0               Mean   : 2804   Mean   :  76.34   Mean   :  2.574  
##  3rd Qu.:0               3rd Qu.: 3140   3rd Qu.:  45.00   3rd Qu.:  3.000  
##  Max.   :0               Max.   :12514   Max.   :7936.00   Max.   :100.000  
##                                                                             
##  final_magicPen   final_magicPenPercent final_magicResist final_movementSpeed
##  Min.   : 0.000   Min.   : 0.000        Min.   : -3.00    Min.   : 129.0     
##  1st Qu.: 0.000   1st Qu.: 0.000        1st Qu.: 48.00    1st Qu.: 380.0     
##  Median : 0.000   Median : 0.000        Median : 55.00    Median : 395.0     
##  Mean   : 5.615   Mean   : 1.913        Mean   : 71.73    Mean   : 405.5     
##  3rd Qu.:12.000   3rd Qu.: 0.000        3rd Qu.: 82.00    3rd Qu.: 415.0     
##  Max.   :49.000   Max.   :48.000        Max.   :515.00    Max.   :1193.0     
##                                                                              
##  final_omnivamp     final_physicalVamp final_powerMax  final_powerRegen 
##  Min.   : 0.00000   Min.   :0          Min.   :    0   Min.   :   0.00  
##  1st Qu.: 0.00000   1st Qu.:0          1st Qu.:  783   1st Qu.:  30.00  
##  Median : 0.00000   Median :0          Median : 1035   Median :  41.00  
##  Mean   : 0.04374   Mean   :0          Mean   : 1257   Mean   :  60.99  
##  3rd Qu.: 0.00000   3rd Qu.:0          3rd Qu.: 1570   3rd Qu.:  67.00  
##  Max.   :25.00000   Max.   :0          Max.   :10000   Max.   :1013.00  
##                                                                         
##  final_spellVamp    
##  Min.   : 0.000000  
##  1st Qu.: 0.000000  
##  Median : 0.000000  
##  Mean   : 0.005616  
##  3rd Qu.: 0.000000  
##  Max.   :26.000000  
## 

We filter the game mode and version we are interested in analyzing.

df_filtered <- df_selected[df_selected$game_mode == "CLASSIC", ]
df_filtered <- df_filtered[df_filtered$game_version == "15.1.649.4112", ]
View(df_filtered)
summary(df_filtered)
##  champion_name        difficulty      herotype           alttype         
##  Length:23096       Min.   :1.000   Length:23096       Length:23096      
##  Class :character   1st Qu.:1.000   Class :character   Class :character  
##  Mode  :character   Median :2.000   Mode  :character   Mode  :character  
##                     Mean   :1.802                                        
##                     3rd Qu.:2.000                                        
##                     Max.   :3.000                                        
##                                                                          
##    resource            stats            rangetype         client_positions  
##  Length:23096       Length:23096       Length:23096       Length:23096      
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##  external_positions     damage        toughness        control     
##  Length:23096       Min.   :1.000   Min.   :1.000   Min.   :1.000  
##  Class :character   1st Qu.:2.000   1st Qu.:1.000   1st Qu.:1.000  
##  Mode  :character   Median :3.000   Median :1.000   Median :2.000  
##                     Mean   :2.474   Mean   :1.572   Mean   :1.968  
##                     3rd Qu.:3.000   3rd Qu.:2.000   3rd Qu.:2.000  
##                     Max.   :3.000   Max.   :3.000   Max.   :3.000  
##                                                                    
##     mobility        utility         style        adaptivetype      
##  Min.   :1.000   Min.   :0.00   Min.   :  0.00   Length:23096      
##  1st Qu.:1.000   1st Qu.:1.00   1st Qu.: 30.00   Class :character  
##  Median :2.000   Median :1.00   Median : 65.00   Mode  :character  
##  Mean   :1.741   Mean   :1.44   Mean   : 57.94                     
##  3rd Qu.:2.000   3rd Qu.:2.00   3rd Qu.: 90.00                     
##  Max.   :3.000   Max.   :3.00   Max.   :100.00                     
##                                                                    
##  game_duration   game_mode         game_version       summoner_level  
##  Min.   : 101   Length:23096       Length:23096       Min.   :  10.0  
##  1st Qu.:1485   Class :character   Class :character   1st Qu.: 214.0  
##  Median :1720   Mode  :character   Mode  :character   Median : 393.0  
##  Mean   :1708                                         Mean   : 419.1  
##  3rd Qu.:1973                                         3rd Qu.: 578.0  
##  Max.   :3307                                         Max.   :2065.0  
##                                                                       
##     win          team_position          kills            deaths      
##  Mode :logical   Length:23096       Min.   : 0.000   Min.   : 0.000  
##  FALSE:11548     Class :character   1st Qu.: 2.000   1st Qu.: 4.000  
##  TRUE :11548     Mode  :character   Median : 5.000   Median : 6.000  
##                                     Mean   : 6.038   Mean   : 6.056  
##                                     3rd Qu.: 9.000   3rd Qu.: 8.000  
##                                     Max.   :38.000   Max.   :28.000  
##                                                                      
##     assists        baron_kills       dragon_kills    gold_earned   
##  Min.   : 0.000   Min.   :0.00000   Min.   :0.000   Min.   :  504  
##  1st Qu.: 4.000   1st Qu.:0.00000   1st Qu.:0.000   1st Qu.: 8488  
##  Median : 7.000   Median :0.00000   Median :0.000   Median :10894  
##  Mean   : 8.314   Mean   :0.06902   Mean   :0.387   Mean   :11005  
##  3rd Qu.:11.000   3rd Qu.:0.00000   3rd Qu.:0.000   3rd Qu.:13462  
##  Max.   :47.000   Max.   :3.00000   Max.   :6.000   Max.   :28214  
##                                                                    
##    gold_spent    total_damage_dealt total_damage_dealt_to_champions
##  Min.   :    0   Min.   :     0     Min.   :     0                 
##  1st Qu.: 7775   1st Qu.: 69082     1st Qu.: 11700                 
##  Median :10025   Median :132291     Median : 19272                 
##  Mean   :10148   Mean   :138999     Mean   : 21314                 
##  3rd Qu.:12450   3rd Qu.:192646     3rd Qu.: 28323                 
##  Max.   :32760   Max.   :699786     Max.   :133964                 
##                                                                    
##  physical_damage_dealt_to_champions magic_damage_dealt_to_champions
##  Min.   :     0                     Min.   :     0                 
##  1st Qu.:  1290                     1st Qu.:  1290                 
##  Median :  5437                     Median :  5578                 
##  Mean   : 10247                     Mean   :  9743                 
##  3rd Qu.: 16496                     3rd Qu.: 14918                 
##  Max.   :119253                     Max.   :128404                 
##                                                                    
##  true_damage_dealt_to_champions damage_dealt_to_objectives
##  Min.   :    0                  Min.   :     0            
##  1st Qu.:  164                  1st Qu.:  3033            
##  Median :  704                  Median :  7937            
##  Mean   : 1324                  Mean   : 13268            
##  3rd Qu.: 1625                  3rd Qu.: 17989            
##  Max.   :32724                  Max.   :102868            
##                                                           
##  damage_dealt_to_turrets total_damage_taken physical_damage_taken
##  Min.   :    0           Min.   :     0     Min.   :    0        
##  1st Qu.:  613           1st Qu.: 17755     1st Qu.: 9186        
##  Median : 2340           Median : 25337     Median :14030        
##  Mean   : 3414           Mean   : 27562     Mean   :15658        
##  3rd Qu.: 5120           3rd Qu.: 35206     3rd Qu.:20529        
##  Max.   :25603           Max.   :160253     Max.   :90175        
##                                                                  
##  magic_damage_taken true_damage_taken time_ccing_others  vision_score   
##  Min.   :     0     Min.   :    0     Min.   :  0.00    Min.   :  0.00  
##  1st Qu.:  5778     1st Qu.:  426     1st Qu.: 11.00    1st Qu.: 12.00  
##  Median :  9414     Median :  899     Median : 22.00    Median : 18.00  
##  Mean   : 10536     Mean   : 1366     Mean   : 27.21    Mean   : 24.54  
##  3rd Qu.: 13928     3rd Qu.: 1723     3rd Qu.: 37.00    3rd Qu.: 28.00  
##  Max.   :101393     Max.   :35558     Max.   :366.00    Max.   :171.00  
##                                                                         
##   wards_placed    wards_killed     solo_tier          solo_rank        
##  Min.   : 0.00   Min.   : 0.000   Length:23096       Length:23096      
##  1st Qu.: 6.00   1st Qu.: 0.000   Class :character   Class :character  
##  Median : 9.00   Median : 2.000   Mode  :character   Mode  :character  
##  Mean   :10.97   Mean   : 2.519                                        
##  3rd Qu.:13.00   3rd Qu.: 4.000                                        
##  Max.   :81.00   Max.   :35.000                                        
##                                                                        
##    solo_wins       solo_losses      flex_tier          flex_rank        
##  Min.   :  0.00   Min.   :  0.00   Length:23096       Length:23096      
##  1st Qu.: 11.00   1st Qu.: 10.00   Class :character   Class :character  
##  Median : 20.00   Median : 18.00   Mode  :character   Mode  :character  
##  Mean   : 24.53   Mean   : 22.37                                        
##  3rd Qu.: 34.00   3rd Qu.: 30.00                                        
##  Max.   :130.00   Max.   :138.00                                        
##  NA's   :2900     NA's   :2900                                          
##    flex_wins       flex_losses     champion_mastery_level
##  Min.   : 0.000   Min.   : 0.000   Min.   :   1.00       
##  1st Qu.: 4.000   1st Qu.: 4.000   1st Qu.:   5.00       
##  Median : 7.000   Median : 6.000   Median :   9.00       
##  Mean   : 9.163   Mean   : 8.375   Mean   :  23.12       
##  3rd Qu.:12.000   3rd Qu.:11.000   3rd Qu.:  22.00       
##  Max.   :93.000   Max.   :80.000   Max.   :1278.00       
##  NA's   :15890    NA's   :15890    NA's   :5             
##  champion_mastery_points final_abilityHaste final_abilityPower  final_armor   
##  Min.   :     359        Min.   :0          Min.   :   0.0     Min.   : 18.0  
##  1st Qu.:   25048        1st Qu.:0          1st Qu.:   0.0     1st Qu.: 83.0  
##  Median :   73884        Median :0          Median :  30.0     Median :100.0  
##  Mean   :  249763        Mean   :0          Mean   : 130.2     Mean   :118.2  
##  3rd Qu.:  240234        3rd Qu.:0          3rd Qu.: 220.0     3rd Qu.:140.0  
##  Max.   :15501091        Max.   :0          Max.   :1675.0     Max.   :869.0  
##  NA's   :5                                                                    
##  final_armorPen final_armorPenPercent final_attackDamage final_attackSpeed
##  Min.   :0      Min.   : 0.000        Min.   : 47.0      Min.   : 60.0    
##  1st Qu.:0      1st Qu.: 0.000        1st Qu.: 98.0      1st Qu.:132.0    
##  Median :0      Median : 0.000        Median :140.0      Median :149.0    
##  Mean   :0      Mean   : 3.838        Mean   :186.8      Mean   :168.3    
##  3rd Qu.:0      3rd Qu.: 0.000        3rd Qu.:265.0      3rd Qu.:193.0    
##  Max.   :0      Max.   :61.000        Max.   :994.0      Max.   :755.0    
##                                                                           
##  final_bonusArmorPenPercent final_bonusMagicPenPercent final_ccReduction
##  Min.   : 0.00000           Min.   :0                  Min.   : 0.000   
##  1st Qu.: 0.00000           1st Qu.:0                  1st Qu.: 0.000   
##  Median : 0.00000           Median :0                  Median : 0.000   
##  Mean   : 0.00649           Mean   :0                  Mean   : 6.048   
##  3rd Qu.: 0.00000           3rd Qu.:0                  3rd Qu.: 5.000   
##  Max.   :50.00000           Max.   :0                  Max.   :73.000   
##                                                                         
##  final_cooldownReduction final_healthMax final_healthRegen final_lifesteal  
##  Min.   :0               Min.   :  540   Min.   :   0.0    Min.   :  0.000  
##  1st Qu.:0               1st Qu.: 2166   1st Qu.:  26.0    1st Qu.:  0.000  
##  Median :0               Median : 2537   Median :  34.0    Median :  0.000  
##  Mean   :0               Mean   : 2695   Mean   :  57.7    Mean   :  2.372  
##  3rd Qu.:0               3rd Qu.: 3079   3rd Qu.:  46.0    3rd Qu.:  3.000  
##  Max.   :0               Max.   :11708   Max.   :7057.0    Max.   :100.000  
##                                                                             
##  final_magicPen   final_magicPenPercent final_magicResist final_movementSpeed
##  Min.   : 0.000   Min.   : 0.000        Min.   : -3.00    Min.   : 129.0     
##  1st Qu.: 0.000   1st Qu.: 0.000        1st Qu.: 47.00    1st Qu.: 385.0     
##  Median : 0.000   Median : 0.000        Median : 54.00    Median : 397.0     
##  Mean   : 4.821   Mean   : 1.566        Mean   : 68.71    Mean   : 410.7     
##  3rd Qu.: 0.000   3rd Qu.: 0.000        3rd Qu.: 78.00    3rd Qu.: 419.0     
##  Max.   :48.000   Max.   :44.000        Max.   :428.00    Max.   :1063.0     
##                                                                              
##  final_omnivamp     final_physicalVamp final_powerMax  final_powerRegen
##  Min.   : 0.00000   Min.   :0          Min.   :    0   Min.   :  0.00  
##  1st Qu.: 0.00000   1st Qu.:0          1st Qu.:  747   1st Qu.: 28.00  
##  Median : 0.00000   Median :0          Median :  986   Median : 37.00  
##  Mean   : 0.04317   Mean   :0          Mean   : 1197   Mean   : 60.36  
##  3rd Qu.: 0.00000   3rd Qu.:0          3rd Qu.: 1411   3rd Qu.: 61.00  
##  Max.   :25.00000   Max.   :0          Max.   :10000   Max.   :682.00  
##                                                                        
##  final_spellVamp    
##  Min.   : 0.000000  
##  1st Qu.: 0.000000  
##  Median : 0.000000  
##  Mean   : 0.007534  
##  3rd Qu.: 0.000000  
##  Max.   :26.000000  
## 

We look at the missing values in each variable.

colSums(is.na(df_filtered))
##                      champion_name                         difficulty 
##                                  0                                  0 
##                           herotype                            alttype 
##                                  0                                  0 
##                           resource                              stats 
##                                  0                                  0 
##                          rangetype                   client_positions 
##                                  0                                  0 
##                 external_positions                             damage 
##                                  0                                  0 
##                          toughness                            control 
##                                  0                                  0 
##                           mobility                            utility 
##                                  0                                  0 
##                              style                       adaptivetype 
##                                  0                                  0 
##                      game_duration                          game_mode 
##                                  0                                  0 
##                       game_version                     summoner_level 
##                                  0                                  0 
##                                win                      team_position 
##                                  0                                 11 
##                              kills                             deaths 
##                                  0                                  0 
##                            assists                        baron_kills 
##                                  0                                  0 
##                       dragon_kills                        gold_earned 
##                                  0                                  0 
##                         gold_spent                 total_damage_dealt 
##                                  0                                  0 
##    total_damage_dealt_to_champions physical_damage_dealt_to_champions 
##                                  0                                  0 
##    magic_damage_dealt_to_champions     true_damage_dealt_to_champions 
##                                  0                                  0 
##         damage_dealt_to_objectives            damage_dealt_to_turrets 
##                                  0                                  0 
##                 total_damage_taken              physical_damage_taken 
##                                  0                                  0 
##                 magic_damage_taken                  true_damage_taken 
##                                  0                                  0 
##                  time_ccing_others                       vision_score 
##                                  0                                  0 
##                       wards_placed                       wards_killed 
##                                  0                                  0 
##                          solo_tier                          solo_rank 
##                               2900                               2900 
##                          solo_wins                        solo_losses 
##                               2900                               2900 
##                          flex_tier                          flex_rank 
##                              15890                              15890 
##                          flex_wins                        flex_losses 
##                              15890                              15890 
##             champion_mastery_level            champion_mastery_points 
##                                  5                                  5 
##                 final_abilityHaste                 final_abilityPower 
##                                  0                                  0 
##                        final_armor                     final_armorPen 
##                                  0                                  0 
##              final_armorPenPercent                 final_attackDamage 
##                                  0                                  0 
##                  final_attackSpeed         final_bonusArmorPenPercent 
##                                  0                                  0 
##         final_bonusMagicPenPercent                  final_ccReduction 
##                                  0                                  0 
##            final_cooldownReduction                    final_healthMax 
##                                  0                                  0 
##                  final_healthRegen                    final_lifesteal 
##                                  0                                  0 
##                     final_magicPen              final_magicPenPercent 
##                                  0                                  0 
##                  final_magicResist                final_movementSpeed 
##                                  0                                  0 
##                     final_omnivamp                 final_physicalVamp 
##                                  0                                  0 
##                     final_powerMax                   final_powerRegen 
##                                  0                                  0 
##                    final_spellVamp 
##                                  0

It can be seen that the vast majority of missing data are concentrated in the same four variables. The amount of missing data for these variables accounts for almost 70% of the observations in the set. To ensure that we have a manageable amount of data, we decided to eliminate the observations with missing data.

df_cleaned <- na.omit(df_filtered) 
View(df_cleaned)

colSums(is.na(df_cleaned))
##                      champion_name                         difficulty 
##                                  0                                  0 
##                           herotype                            alttype 
##                                  0                                  0 
##                           resource                              stats 
##                                  0                                  0 
##                          rangetype                   client_positions 
##                                  0                                  0 
##                 external_positions                             damage 
##                                  0                                  0 
##                          toughness                            control 
##                                  0                                  0 
##                           mobility                            utility 
##                                  0                                  0 
##                              style                       adaptivetype 
##                                  0                                  0 
##                      game_duration                          game_mode 
##                                  0                                  0 
##                       game_version                     summoner_level 
##                                  0                                  0 
##                                win                      team_position 
##                                  0                                  0 
##                              kills                             deaths 
##                                  0                                  0 
##                            assists                        baron_kills 
##                                  0                                  0 
##                       dragon_kills                        gold_earned 
##                                  0                                  0 
##                         gold_spent                 total_damage_dealt 
##                                  0                                  0 
##    total_damage_dealt_to_champions physical_damage_dealt_to_champions 
##                                  0                                  0 
##    magic_damage_dealt_to_champions     true_damage_dealt_to_champions 
##                                  0                                  0 
##         damage_dealt_to_objectives            damage_dealt_to_turrets 
##                                  0                                  0 
##                 total_damage_taken              physical_damage_taken 
##                                  0                                  0 
##                 magic_damage_taken                  true_damage_taken 
##                                  0                                  0 
##                  time_ccing_others                       vision_score 
##                                  0                                  0 
##                       wards_placed                       wards_killed 
##                                  0                                  0 
##                          solo_tier                          solo_rank 
##                                  0                                  0 
##                          solo_wins                        solo_losses 
##                                  0                                  0 
##                          flex_tier                          flex_rank 
##                                  0                                  0 
##                          flex_wins                        flex_losses 
##                                  0                                  0 
##             champion_mastery_level            champion_mastery_points 
##                                  0                                  0 
##                 final_abilityHaste                 final_abilityPower 
##                                  0                                  0 
##                        final_armor                     final_armorPen 
##                                  0                                  0 
##              final_armorPenPercent                 final_attackDamage 
##                                  0                                  0 
##                  final_attackSpeed         final_bonusArmorPenPercent 
##                                  0                                  0 
##         final_bonusMagicPenPercent                  final_ccReduction 
##                                  0                                  0 
##            final_cooldownReduction                    final_healthMax 
##                                  0                                  0 
##                  final_healthRegen                    final_lifesteal 
##                                  0                                  0 
##                     final_magicPen              final_magicPenPercent 
##                                  0                                  0 
##                  final_magicResist                final_movementSpeed 
##                                  0                                  0 
##                     final_omnivamp                 final_physicalVamp 
##                                  0                                  0 
##                     final_powerMax                   final_powerRegen 
##                                  0                                  0 
##                    final_spellVamp 
##                                  0

Now we will perform the analysis of atypical data.

# Seleccionar solo variables numéricas
datos_numericos <- df_cleaned %>% select_if(is.numeric)

# Crear histogramas y boxplots automáticamente
for (columna in colnames(datos_numericos)) {
  # Histograma
  print(ggplot(data = df_cleaned, aes_string(x = columna)) +
    geom_histogram(bins = 30, fill = "blue", color = "black", alpha = 0.7) +
    labs(title = paste("Histograma de", columna), x = columna, y = "Frecuencia"))

  # Boxplot
  print(ggplot(data = df_cleaned, aes_string(x = columna)) +
    geom_boxplot() +
    theme(
      axis.text.y = element_blank(),   # Remove y-axis text
      axis.ticks.y = element_blank(),  # Remove y-axis ticks
      axis.title.y = element_blank(),  # Remove y-axis title
      axis.line.y = element_blank()    # Remove y-axis line
    ) +
    labs(title = paste("Boxplot de", columna), x = columna)) 
}
## Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
## ℹ Please use tidy evaluation idioms with `aes()`.
## ℹ See also `vignette("ggplot2-in-packages")` for more information.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

And now the categorical ones.

# Seleccionar solo variables categóricas
datos_categoricos <- df_cleaned %>% select_if(is.character)

# Crear gráficos de barras automáticamente
for (columna in colnames(datos_categoricos)) {
  print(ggplot(data = df_cleaned, aes_string(x = columna)) +
    geom_bar(fill = "purple", color = "black", alpha = 0.7) +
    labs(title = paste("Gráfico de barras de", columna), x = columna, y = "Frecuencia") +
    theme(axis.text.x = element_text(angle = 45, hjust = 1)))
}

In light of the previous analyses, we’ll eliminate variables that have almost no variability or that we no longer consider useful. Regarding outliers, these are values from players who stand out for their excellent performance, so they won’t be eliminated. This is because they can be useful, as League of Legends is a highly complex video game, and these outliers can provide information about exceptional players.

cols_eliminar <- c("game_mode", "game_version", "solo_rank", "flex_rank",
                   "final_abilityHaste", "final_armorPen", "final_magicPen",
                   "final_bonusArmorPenPercent", "final_bonusMagicPenPercent",
                   "final_cooldownReduction", "final_healthRegen", "final_powerRegen",
                   "final_omnivamp", "final_physicalVamp", "final_spellVamp")

df_full_cleaned <- df_cleaned[, !names(df_cleaned) %in% cols_eliminar]
View(df_full_cleaned)

We save the data in a CSV for use in the objectives.

write.csv(df_full_cleaned, file = "lol_dataset.csv", row.names = FALSE)