knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5     ✓ purrr   0.3.4
## ✓ tibble  3.1.6     ✓ dplyr   1.0.8
## ✓ tidyr   1.2.0     ✓ stringr 1.4.0
## ✓ readr   2.1.2     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(csv)
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
library(magrittr)
## 
## Attaching package: 'magrittr'
## The following object is masked from 'package:purrr':
## 
##     set_names
## The following object is masked from 'package:tidyr':
## 
##     extract
library(cowplot)
## 
## Attaching package: 'cowplot'
## The following object is masked from 'package:lubridate':
## 
##     stamp
data <- as.csv("2021_LoL_esports_match_data_from_OraclesElixir_20220322.csv")


summary(data)
##     gameid          datacompleteness       url               league         
##  Length:148020      Length:148020      Length:148020      Length:148020     
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##       year         split              playoffs          date          
##  Min.   :2020   Length:148020      Min.   :0.0000   Length:148020     
##  1st Qu.:2021   Class :character   1st Qu.:0.0000   Class :character  
##  Median :2021   Mode  :character   Median :0.0000   Mode  :character  
##  Mean   :2021                      Mean   :0.1661                     
##  3rd Qu.:2021                      3rd Qu.:0.0000                     
##  Max.   :2022                      Max.   :1.0000                     
##                                                                       
##       game           patch       participantid        side          
##  Min.   :1.000   Min.   :10.25   Min.   :  1.00   Length:148020     
##  1st Qu.:1.000   1st Qu.:11.03   1st Qu.:  3.75   Class :character  
##  Median :1.000   Median :11.11   Median :  6.50   Mode  :character  
##  Mean   :1.556   Mean   :11.09   Mean   : 29.58                     
##  3rd Qu.:2.000   3rd Qu.:11.14   3rd Qu.:  9.25                     
##  Max.   :5.000   Max.   :11.24   Max.   :200.00                     
##                                                                     
##    position          playername          playerid           teamname        
##  Length:148020      Length:148020      Length:148020      Length:148020     
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##     teamid            champion             ban1               ban2          
##  Length:148020      Length:148020      Length:148020      Length:148020     
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##      ban3               ban4               ban5             gamelength     
##  Length:148020      Length:148020      Length:148020      Min.   :    911  
##  Class :character   Class :character   Class :character   1st Qu.:   1653  
##  Mode  :character   Mode  :character   Mode  :character   Median :   1850  
##                                                           Mean   :   7869  
##                                                           3rd Qu.:   2080  
##                                                           Max.   :2442645  
##                                                                            
##      result        kills            deaths          assists      
##  Min.   :0.0   Min.   : 0.000   Min.   : 0.000   Min.   :  0.00  
##  1st Qu.:0.0   1st Qu.: 1.000   1st Qu.: 2.000   1st Qu.:  4.00  
##  Median :0.0   Median : 3.000   Median : 3.000   Median :  7.00  
##  Mean   :0.5   Mean   : 4.903   Mean   : 4.914   Mean   : 10.97  
##  3rd Qu.:1.0   3rd Qu.: 6.000   3rd Qu.: 5.000   3rd Qu.: 12.00  
##  Max.   :1.0   Max.   :53.000   Max.   :53.000   Max.   :110.00  
##                                                                  
##    teamkills       teamdeaths     doublekills      triplekills   
##  Min.   : 0.00   Min.   : 0.00   Min.   : 0.000   Min.   :0.000  
##  1st Qu.: 8.00   1st Qu.: 8.00   1st Qu.: 0.000   1st Qu.:0.000  
##  Median :15.00   Median :15.00   Median : 0.000   Median :0.000  
##  Mean   :14.71   Mean   :14.74   Mean   : 0.569   Mean   :0.103  
##  3rd Qu.:20.00   3rd Qu.:20.00   3rd Qu.: 1.000   3rd Qu.:0.000  
##  Max.   :53.00   Max.   :53.00   Max.   :10.000   Max.   :5.000  
##                                  NA's   :12588    NA's   :12588  
##   quadrakills      pentakills      firstblood    firstbloodkill 
##  Min.   :0.000   Min.   :0.000   Min.   :0.000   Min.   :0.0    
##  1st Qu.:0.000   1st Qu.:0.000   1st Qu.:0.000   1st Qu.:0.0    
##  Median :0.000   Median :0.000   Median :0.000   Median :0.0    
##  Mean   :0.017   Mean   :0.003   Mean   :0.291   Mean   :0.1    
##  3rd Qu.:0.000   3rd Qu.:0.000   3rd Qu.:1.000   3rd Qu.:0.0    
##  Max.   :3.000   Max.   :2.000   Max.   :1.000   Max.   :1.0    
##  NA's   :14742   NA's   :14742   NA's   :21218   NA's   :24710  
##  firstbloodassist firstbloodvictim    team kpm           ckpm       
##  Min.   :0.00     Min.   :0.0      Min.   :0.0000   Min.   :0.0006  
##  1st Qu.:0.00     1st Qu.:0.0      1st Qu.:0.2710   1st Qu.:0.7305  
##  Median :0.00     Median :0.0      Median :0.4442   Median :0.9091  
##  Mean   :0.14     Mean   :0.1      Mean   :0.4746   Mean   :0.9492  
##  3rd Qu.:0.00     3rd Qu.:0.0      3rd Qu.:0.6368   3rd Qu.:1.1258  
##  Max.   :1.00     Max.   :1.0      Max.   :2.6158   Max.   :3.8549  
##  NA's   :35360    NA's   :35360                                     
##   firstdragon        dragons        opp_dragons     elementaldrakes 
##  Min.   :0.0      Min.   :0.00     Min.   :0.00     Min.   :0.00    
##  1st Qu.:0.0      1st Qu.:1.00     1st Qu.:1.00     1st Qu.:1.00    
##  Median :0.5      Median :2.00     Median :2.00     Median :2.00    
##  Mean   :0.5      Mean   :2.24     Mean   :2.24     Mean   :2.15    
##  3rd Qu.:1.0      3rd Qu.:3.00     3rd Qu.:3.00     3rd Qu.:3.00    
##  Max.   :1.0      Max.   :7.00     Max.   :7.00     Max.   :4.00    
##  NA's   :125494   NA's   :123434   NA's   :123434   NA's   :145408  
##  opp_elementaldrakes   infernals        mountains          clouds      
##  Min.   :0.00        Min.   :0.00     Min.   :0.00     Min.   :0.00    
##  1st Qu.:1.00        1st Qu.:0.00     1st Qu.:0.00     1st Qu.:0.00    
##  Median :2.00        Median :0.00     Median :0.00     Median :0.00    
##  Mean   :2.15        Mean   :0.55     Mean   :0.54     Mean   :0.54    
##  3rd Qu.:3.00        3rd Qu.:1.00     3rd Qu.:1.00     3rd Qu.:1.00    
##  Max.   :4.00        Max.   :4.00     Max.   :4.00     Max.   :4.00    
##  NA's   :145408      NA's   :125586   NA's   :125586   NA's   :125586  
##      oceans         chemtechs         hextechs      dragons (type unknown)
##  Min.   :0.00     Min.   :0.00     Min.   :0.00     Min.   :0.00          
##  1st Qu.:0.00     1st Qu.:0.00     1st Qu.:0.00     1st Qu.:1.00          
##  Median :0.00     Median :0.00     Median :0.00     Median :2.00          
##  Mean   :0.55     Mean   :0.04     Mean   :0.04     Mean   :2.17          
##  3rd Qu.:1.00     3rd Qu.:0.00     3rd Qu.:0.00     3rd Qu.:3.00          
##  Max.   :4.00     Max.   :3.00     Max.   :3.00     Max.   :6.00          
##  NA's   :125586   NA's   :145324   NA's   :145324   NA's   :143767        
##      elders         opp_elders      firstherald        heralds      
##  Min.   :0.00     Min.   :0.00     Min.   :0.0      Min.   :0.00    
##  1st Qu.:0.00     1st Qu.:0.00     1st Qu.:0.0      1st Qu.:0.00    
##  Median :0.00     Median :0.00     Median :0.0      Median :1.00    
##  Mean   :0.05     Mean   :0.05     Mean   :0.5      Mean   :0.97    
##  3rd Qu.:0.00     3rd Qu.:0.00     3rd Qu.:1.0      3rd Qu.:2.00    
##  Max.   :3.00     Max.   :3.00     Max.   :1.0      Max.   :2.00    
##  NA's   :125586   NA's   :125586   NA's   :125488   NA's   :127596  
##   opp_heralds       firstbaron         barons         opp_barons    
##  Min.   :0.00     Min.   :0.00     Min.   :0.00     Min.   :0.00    
##  1st Qu.:0.00     1st Qu.:0.00     1st Qu.:0.00     1st Qu.:0.00    
##  Median :1.00     Median :0.00     Median :0.00     Median :0.00    
##  Mean   :0.97     Mean   :0.47     Mean   :0.47     Mean   :0.47    
##  3rd Qu.:2.00     3rd Qu.:1.00     3rd Qu.:1.00     3rd Qu.:1.00    
##  Max.   :2.00     Max.   :1.00     Max.   :4.00     Max.   :4.00    
##  NA's   :127596   NA's   :125606   NA's   :109870   NA's   :109870  
##    firsttower         towers         opp_towers     firstmidtower   
##  Min.   :0.0      Min.   : 0.00    Min.   : 0.00    Min.   :0.0     
##  1st Qu.:0.0      1st Qu.: 2.00    1st Qu.: 2.00    1st Qu.:0.0     
##  Median :0.0      Median : 7.00    Median : 7.00    Median :0.5     
##  Mean   :0.5      Mean   : 5.86    Mean   : 5.86    Mean   :0.5     
##  3rd Qu.:1.0      3rd Qu.: 9.00    3rd Qu.: 9.00    3rd Qu.:1.0     
##  Max.   :1.0      Max.   :11.00    Max.   :11.00    Max.   :1.0     
##  NA's   :125450   NA's   :123350   NA's   :123350   NA's   :125498  
##  firsttothreetowers  turretplates    opp_turretplates   inhibitors    
##  Min.   :0.0        Min.   : 0.00    Min.   : 0.00    Min.   : 0.000  
##  1st Qu.:0.0        1st Qu.: 3.00    1st Qu.: 3.00    1st Qu.: 0.000  
##  Median :0.0        Median : 5.00    Median : 5.00    Median : 0.000  
##  Mean   :0.5        Mean   : 4.91    Mean   : 4.91    Mean   : 0.314  
##  3rd Qu.:1.0        3rd Qu.: 7.00    3rd Qu.: 7.00    3rd Qu.: 0.000  
##  Max.   :1.0        Max.   :15.00    Max.   :15.00    Max.   :10.000  
##  NA's   :125488     NA's   :145324   NA's   :145324   NA's   :21670   
##  opp_inhibitors   damagetochampions      dpm            damageshare   
##  Min.   : 0.000   Min.   :   259    Min.   :   0.039   Min.   :0.008  
##  1st Qu.: 0.000   1st Qu.:  7798    1st Qu.: 260.153   1st Qu.:0.128  
##  Median : 0.000   Median : 13230    Median : 430.622   Median :0.201  
##  Mean   : 0.314   Mean   : 21009    Mean   : 661.022   Mean   :0.200  
##  3rd Qu.: 0.000   3rd Qu.: 22340    3rd Qu.: 679.793   3rd Qu.:0.263  
##  Max.   :10.000   Max.   :253331    Max.   :4715.737   Max.   :0.662  
##  NA's   :21670    NA's   :48        NA's   :48         NA's   :24710  
##  damagetakenperminute damagemitigatedperminute  wardsplaced    
##  Min.   :   0.115     Min.   :   0.065         Min.   :  0.00  
##  1st Qu.: 414.967     1st Qu.: 294.578         1st Qu.: 11.00  
##  Median : 602.190     Median : 520.735         Median : 15.00  
##  Mean   : 966.692     Mean   : 837.336         Mean   : 32.92  
##  3rd Qu.: 936.933     3rd Qu.: 905.979         3rd Qu.: 45.00  
##  Max.   :5637.273     Max.   :6856.867         Max.   :326.00  
##  NA's   :48           NA's   :12600            NA's   :48      
##       wpm          wardskilled          wcpm        controlwardsbought
##  Min.   :0.0000   Min.   :  0.00   Min.   :0.0000   Min.   :  0.00    
##  1st Qu.:0.3536   1st Qu.:  5.00   1st Qu.:0.1657   1st Qu.:  4.00    
##  Median :0.4775   Median :  9.00   Median :0.2805   Median :  8.00    
##  Mean   :1.0336   Mean   : 14.23   Mean   :0.4423   Mean   : 12.91    
##  3rd Qu.:1.4366   3rd Qu.: 16.00   3rd Qu.:0.4784   3rd Qu.: 15.00    
##  Max.   :6.3345   Max.   :186.00   Max.   :3.1713   Max.   :103.00    
##  NA's   :48       NA's   :48       NA's   :48       NA's   :48        
##   visionscore          vspm          totalgold        earnedgold       
##  Min.   :  1.00   Min.   : 0.000   Min.   :  2917   Min.   :-24854999  
##  1st Qu.: 29.00   1st Qu.: 0.961   1st Qu.:  9164   1st Qu.:     5248  
##  Median : 43.00   Median : 1.324   Median : 11850   Median :     7752  
##  Mean   : 74.74   Mean   : 2.332   Mean   : 18587   Mean   :    -8629  
##  3rd Qu.: 81.00   3rd Qu.: 2.536   3rd Qu.: 15408   3rd Qu.:    10791  
##  Max.   :730.00   Max.   :13.815   Max.   :120870   Max.   :    76489  
##  NA's   :12900    NA's   :12900                     NA's   :8          
##    earned gpm     earnedgoldshare    goldspent           gspd       
##  Min.   :-610.7   Min.   :-3.786   Min.   :  2295   Min.   :-0.59   
##  1st Qu.: 180.1   1st Qu.: 0.165   1st Qu.:  8550   1st Qu.:-0.11   
##  Median : 248.7   Median : 0.210   Median : 10950   Median : 0.00   
##  Mean   : 372.4   Mean   : 0.200   Mean   : 17201   Mean   : 0.00   
##  3rd Qu.: 331.4   3rd Qu.: 0.246   3rd Qu.: 14369   3rd Qu.: 0.11   
##  Max.   :2048.5   Max.   : 6.403   Max.   :130820   Max.   : 0.59   
##  NA's   :8        NA's   :24670    NA's   :48       NA's   :123358  
##     total cs       minionkills      monsterkills    monsterkillsownjungle
##  Min.   :   1.0   Min.   :   1.0   Min.   :  0.00   Min.   :  0.00       
##  1st Qu.: 151.0   1st Qu.:  40.0   1st Qu.:  4.00   1st Qu.:  1.00       
##  Median : 213.0   Median : 210.0   Median : 20.00   Median : 13.00       
##  Mean   : 210.8   Mean   : 251.7   Mean   : 68.85   Mean   : 45.59       
##  3rd Qu.: 267.0   3rd Qu.: 282.0   3rd Qu.:145.00   3rd Qu.: 97.00       
##  Max.   :1639.0   Max.   :1744.0   Max.   :522.00   Max.   :309.00       
##  NA's   :22520    NA's   :2222     NA's   :48       NA's   :16224        
##  monsterkillsenemyjungle      cspm            goldat10         xpat10     
##  Min.   :  0.000         Min.   : 0.0001   Min.   : 1728   Min.   : 1017  
##  1st Qu.:  0.000         1st Qu.: 5.5977   1st Qu.: 2983   1st Qu.: 3127  
##  Median :  1.000         Median : 7.5696   Median : 3316   Median : 4004  
##  Mean   :  6.295         Mean   :10.1314   Mean   : 5242   Mean   : 6104  
##  3rd Qu.:  8.000         3rd Qu.: 9.2953   3rd Qu.: 3791   3rd Qu.: 4787  
##  Max.   :132.000         Max.   :41.2028   Max.   :24250   Max.   :22663  
##  NA's   :16224           NA's   :2174      NA's   :12840   NA's   :12840  
##      csat10       opp_goldat10     opp_xpat10      opp_csat10   
##  Min.   :  0.0   Min.   : 1728   Min.   : 1017   Min.   :  0.0  
##  1st Qu.: 61.0   1st Qu.: 2983   1st Qu.: 3127   1st Qu.: 61.0  
##  Median : 76.0   Median : 3316   Median : 4004   Median : 76.0  
##  Mean   :105.5   Mean   : 5242   Mean   : 6104   Mean   :105.5  
##  3rd Qu.: 90.0   3rd Qu.: 3791   3rd Qu.: 4787   3rd Qu.: 90.0  
##  Max.   :403.0   Max.   :24250   Max.   :22663   Max.   :403.0  
##  NA's   :12840   NA's   :12840   NA's   :12840   NA's   :12840  
##   golddiffat10     xpdiffat10      csdiffat10      killsat10     
##  Min.   :-9561   Min.   :-6464   Min.   :-140    Min.   : 0.000  
##  1st Qu.: -363   1st Qu.: -340   1st Qu.:  -9    1st Qu.: 0.000  
##  Median :    0   Median :    0   Median :   0    Median : 0.000  
##  Mean   :    0   Mean   :    0   Mean   :   0    Mean   : 0.802  
##  3rd Qu.:  363   3rd Qu.:  340   3rd Qu.:   9    3rd Qu.: 1.000  
##  Max.   : 9561   Max.   : 6464   Max.   : 140    Max.   :19.000  
##  NA's   :12840   NA's   :12840   NA's   :12840   NA's   :12840   
##   assistsat10      deathsat10     opp_killsat10    opp_assistsat10
##  Min.   : 0.00   Min.   : 0.000   Min.   : 0.000   Min.   : 0.00  
##  1st Qu.: 0.00   1st Qu.: 0.000   1st Qu.: 0.000   1st Qu.: 0.00  
##  Median : 1.00   Median : 0.000   Median : 0.000   Median : 1.00  
##  Mean   : 1.24   Mean   : 0.805   Mean   : 0.802   Mean   : 1.24  
##  3rd Qu.: 2.00   3rd Qu.: 1.000   3rd Qu.: 1.000   3rd Qu.: 2.00  
##  Max.   :32.00   Max.   :19.000   Max.   :19.000   Max.   :32.00  
##  NA's   :12840   NA's   :12840    NA's   :12840    NA's   :12840  
##  opp_deathsat10      goldat15         xpat15          csat15     
##  Min.   : 0.000   Min.   : 2520   Min.   : 2183   Min.   :  0.0  
##  1st Qu.: 0.000   1st Qu.: 4639   1st Qu.: 5217   1st Qu.: 96.0  
##  Median : 0.000   Median : 5261   Median : 6416   Median :122.0  
##  Mean   : 0.805   Mean   : 8291   Mean   : 9799   Mean   :167.5  
##  3rd Qu.: 1.000   3rd Qu.: 6128   3rd Qu.: 7609   3rd Qu.:143.0  
##  Max.   :19.000   Max.   :39960   Max.   :36028   Max.   :628.0  
##  NA's   :12840    NA's   :12840   NA's   :12840   NA's   :12840  
##   opp_goldat15     opp_xpat15      opp_csat15     golddiffat15   
##  Min.   : 2520   Min.   : 2183   Min.   :  0.0   Min.   :-16402  
##  1st Qu.: 4639   1st Qu.: 5217   1st Qu.: 96.0   1st Qu.:  -691  
##  Median : 5261   Median : 6416   Median :122.0   Median :     0  
##  Mean   : 8291   Mean   : 9799   Mean   :167.5   Mean   :     0  
##  3rd Qu.: 6128   3rd Qu.: 7609   3rd Qu.:143.0   3rd Qu.:   691  
##  Max.   :39960   Max.   :36028   Max.   :628.0   Max.   : 16402  
##  NA's   :12840   NA's   :12840   NA's   :12840   NA's   :12840   
##    xpdiffat15       csdiffat15      killsat15       assistsat15    
##  Min.   :-11914   Min.   :-237    Min.   : 0.000   Min.   : 0.000  
##  1st Qu.:  -576   1st Qu.: -13    1st Qu.: 0.000   1st Qu.: 0.000  
##  Median :     0   Median :   0    Median : 1.000   Median : 1.000  
##  Mean   :     0   Mean   :   0    Mean   : 1.475   Mean   : 2.462  
##  3rd Qu.:   576   3rd Qu.:  13    3rd Qu.: 2.000   3rd Qu.: 3.000  
##  Max.   : 11914   Max.   : 237    Max.   :32.000   Max.   :50.000  
##  NA's   :12840    NA's   :12840   NA's   :12840    NA's   :12840   
##    deathsat15     opp_killsat15    opp_assistsat15  opp_deathsat15  
##  Min.   : 0.000   Min.   : 0.000   Min.   : 0.000   Min.   : 0.000  
##  1st Qu.: 0.000   1st Qu.: 0.000   1st Qu.: 0.000   1st Qu.: 0.000  
##  Median : 1.000   Median : 1.000   Median : 1.000   Median : 1.000  
##  Mean   : 1.479   Mean   : 1.475   Mean   : 2.462   Mean   : 1.479  
##  3rd Qu.: 2.000   3rd Qu.: 2.000   3rd Qu.: 3.000   3rd Qu.: 2.000  
##  Max.   :32.000   Max.   :32.000   Max.   :50.000   Max.   :32.000  
##  NA's   :12840    NA's   :12840    NA's   :12840    NA's   :12840
all_data <- data %>%
  as_tibble()
###################################                                                                 
player_data <- all_data %>%
  filter(playername != is.na(playername) &                                 
           datacompleteness == "complete") %>%                     
  select(-c("url",                                                 
            "playerid",                                         
            "gameid",                                              
            "game",                                                            
            "teamkills",                                          
            "teamdeaths",                                          
            "patch",                                               
            "team kpm":"opp_inhibitors",                           
            "gspd",                                               
            "ban1":"ban5",                                        
            "wcpm":"controlwardsbought",                           
            "earnedgoldshare","goldspent",                        
            "year",                                              
            "split"))

####——————————Converting variables——————————####

player_data$playoffs <- as.factor(player_data$playoffs)
player_data$firstblood <- as.factor(player_data$firstblood)
player_data$firstbloodkill <- as.factor(player_data$firstbloodkill)
player_data$firstbloodassist <- as.factor(player_data$firstbloodassist)
player_data$firstbloodvictim <- as.factor(player_data$firstbloodvictim)
player_data$result <- as.factor(player_data$result)
player_data$side <- as.factor(player_data$side)
player_data$position <- as.factor(player_data$position)



date <- as.Date(player_data$date, "%m/%d/%Y")                    
player_data$date <- date
class(player_data$date)
## [1] "Date"
head(player_data)
## # A tibble: 6 × 73
##   datacompleteness league playoffs date   participantid side  position
##   <chr>            <chr>  <fct>    <date>         <int> <fct> <fct>   
## 1 complete         KeSPA  0        NA                 1 Blue  top     
## 2 complete         KeSPA  0        NA                 2 Blue  jng     
## 3 complete         KeSPA  0        NA                 3 Blue  mid     
## 4 complete         KeSPA  0        NA                 4 Blue  bot     
## 5 complete         KeSPA  0        NA                 5 Blue  sup     
## 6 complete         KeSPA  0        NA                 6 Red   top     
## # … with 66 more variables: playername <chr>, teamname <chr>, teamid <chr>,
## #   champion <chr>, gamelength <int>, result <fct>, kills <int>, deaths <int>,
## #   assists <int>, doublekills <int>, triplekills <int>, quadrakills <int>,
## #   pentakills <int>, firstblood <fct>, firstbloodkill <fct>,
## #   firstbloodassist <fct>, firstbloodvictim <fct>, damagetochampions <int>,
## #   dpm <dbl>, damageshare <dbl>, damagetakenperminute <dbl>,
## #   damagemitigatedperminute <dbl>, wardsplaced <int>, wpm <dbl>, …
class(player_data$date)
## [1] "Date"
class(player_data$teamname)
## [1] "character"
summary(player_data)
##  datacompleteness      league          playoffs       date       
##  Length:112170      Length:112170      0:92660   Min.   :NA      
##  Class :character   Class :character   1:19510   1st Qu.:NA      
##  Mode  :character   Mode  :character             Median :NA      
##                                                  Mean   :NA      
##                                                  3rd Qu.:NA      
##                                                  Max.   :NA      
##                                                  NA's   :112170  
##  participantid    side       position     playername          teamname        
##  Min.   : 1.0   Blue:56085   bot:22434   Length:112170      Length:112170     
##  1st Qu.: 3.0   Red :56085   jng:22434   Class :character   Class :character  
##  Median : 5.5                mid:22434   Mode  :character   Mode  :character  
##  Mean   : 5.5                sup:22434                                        
##  3rd Qu.: 8.0                top:22434                                        
##  Max.   :10.0                                                                 
##                                                                               
##     teamid            champion           gamelength      result   
##  Length:112170      Length:112170      Min.   :    911   0:56085  
##  Class :character   Class :character   1st Qu.:   1654   1:56085  
##  Mode  :character   Mode  :character   Median :   1850            
##                                        Mean   :   3218            
##                                        3rd Qu.:   2078            
##                                        Max.   :2442645            
##                                                                   
##      kills           deaths          assists        doublekills    
##  Min.   : 0.00   Min.   : 0.000   Min.   : 0.000   Min.   :0.0000  
##  1st Qu.: 1.00   1st Qu.: 1.000   1st Qu.: 3.000   1st Qu.:0.0000  
##  Median : 2.00   Median : 3.000   Median : 6.000   Median :0.0000  
##  Mean   : 2.95   Mean   : 2.957   Mean   : 6.575   Mean   :0.3408  
##  3rd Qu.: 4.00   3rd Qu.: 4.000   3rd Qu.: 9.000   3rd Qu.:0.0000  
##  Max.   :24.00   Max.   :14.000   Max.   :32.000   Max.   :7.0000  
##                                                                    
##   triplekills       quadrakills       pentakills      firstblood  
##  Min.   :0.00000   Min.   :0.0000   Min.   :0.00000   0   :77242  
##  1st Qu.:0.00000   1st Qu.:0.0000   1st Qu.:0.00000   1   :24478  
##  Median :0.00000   Median :0.0000   Median :0.00000   NA's:10450  
##  Mean   :0.06187   Mean   :0.0106   Mean   :0.00177               
##  3rd Qu.:0.00000   3rd Qu.:0.0000   3rd Qu.:0.00000               
##  Max.   :3.00000   Max.   :3.0000   Max.   :2.00000               
##                    NA's   :40       NA's   :40                    
##  firstbloodkill firstbloodassist firstbloodvictim damagetochampions
##  0   :100917    0:96412          0:100953         Min.   :  259    
##  1   : 11213    1:15758          1: 11217         1st Qu.: 6872    
##  NA's:    40                                      Median :11353    
##                                                   Mean   :12588    
##                                                   3rd Qu.:16615    
##                                                   Max.   :91030    
##                                                   NA's   :40       
##       dpm             damageshare      damagetakenperminute
##  Min.   :   0.0813   Min.   :0.00823   Min.   :   0.2235   
##  1st Qu.: 230.2142   1st Qu.:0.12847   1st Qu.: 391.8839   
##  Median : 375.5234   Median :0.20098   Median : 527.6758   
##  Mean   : 397.4380   Mean   :0.20000   Mean   : 582.3517   
##  3rd Qu.: 528.7118   3rd Qu.:0.26241   3rd Qu.: 754.1684   
##  Max.   :1869.2671   Max.   :0.66198   Max.   :2109.9085   
##  NA's   :40          NA's   :40        NA's   :40          
##  damagemitigatedperminute  wardsplaced          wpm          wardskilled    
##  Min.   :   0.121         Min.   :  0.00   Min.   :0.0000   Min.   : 0.000  
##  1st Qu.: 267.110         1st Qu.: 10.00   1st Qu.:0.3367   1st Qu.: 4.000  
##  Median : 441.433         Median : 14.00   Median :0.4330   Median : 7.000  
##  Mean   : 503.533         Mean   : 19.75   Mean   :0.6213   Mean   : 8.478  
##  3rd Qu.: 667.532         3rd Qu.: 22.00   3rd Qu.:0.6511   3rd Qu.:11.000  
##  Max.   :3653.578         Max.   :177.00   Max.   :3.5616   Max.   :61.000  
##                           NA's   :40       NA's   :40       NA's   :40      
##   visionscore          vspm         totalgold       earnedgold      
##  Min.   :  1.00   Min.   :0.000   Min.   : 2917   Min.   :-4975504  
##  1st Qu.: 27.00   1st Qu.:0.909   1st Qu.: 8678   1st Qu.:    4755  
##  Median : 38.00   Median :1.188   Median :10986   Median :    6998  
##  Mean   : 44.84   Mean   :1.401   Mean   :11145   Mean   :    4305  
##  3rd Qu.: 56.00   3rd Qu.:1.704   3rd Qu.:13253   3rd Qu.:    8978  
##  Max.   :262.00   Max.   :6.094   Max.   :29732   Max.   :   22408  
##  NA's   :10450    NA's   :10450                                     
##    earned gpm        total cs      minionkills     monsterkills   
##  Min.   :-122.2   Min.   :  1.0   Min.   :  1.0   Min.   :  0.00  
##  1st Qu.: 165.1   1st Qu.:149.0   1st Qu.: 36.0   1st Qu.:  2.00  
##  Median : 227.3   Median :211.0   Median :187.0   Median : 14.00  
##  Mean   : 224.2   Mean   :196.8   Mean   :155.6   Mean   : 41.25  
##  3rd Qu.: 283.6   3rd Qu.:264.0   3rd Qu.:244.0   3rd Qu.: 38.00  
##  Max.   : 651.7   Max.   :645.0   Max.   :578.0   Max.   :347.00  
##                                   NA's   :40      NA's   :40      
##  monsterkillsownjungle monsterkillsenemyjungle      cspm            goldat10   
##  Min.   :  0.00        Min.   : 0.000          Min.   : 0.0007   Min.   :1728  
##  1st Qu.:  0.00        1st Qu.: 0.000          1st Qu.: 5.1411   1st Qu.:2883  
##  Median :  8.00        Median : 0.000          Median : 7.0393   Median :3217  
##  Mean   : 27.28        Mean   : 3.789          Mean   : 6.2788   Mean   :3145  
##  3rd Qu.: 26.00        3rd Qu.: 4.000          3rd Qu.: 8.4192   3rd Qu.:3491  
##  Max.   :232.00        Max.   :86.000          Max.   :13.1588   Max.   :6545  
##  NA's   :13180         NA's   :13180                                           
##      xpat10         csat10        opp_goldat10    opp_xpat10     opp_csat10    
##  Min.   :1017   Min.   :  0.00   Min.   :1728   Min.   :1017   Min.   :  0.00  
##  1st Qu.:2981   1st Qu.: 56.00   1st Qu.:2883   1st Qu.:2981   1st Qu.: 56.00  
##  Median :3641   Median : 72.00   Median :3217   Median :3641   Median : 72.00  
##  Mean   :3662   Mean   : 63.28   Mean   :3145   Mean   :3662   Mean   : 63.28  
##  3rd Qu.:4464   3rd Qu.: 83.00   3rd Qu.:3491   3rd Qu.:4464   3rd Qu.: 83.00  
##  Max.   :5979   Max.   :115.00   Max.   :6545   Max.   :5979   Max.   :115.00  
##                                                                                
##   golddiffat10     xpdiffat10      csdiffat10    killsat10      
##  Min.   :-3860   Min.   :-3303   Min.   :-97   Min.   : 0.0000  
##  1st Qu.: -310   1st Qu.: -302   1st Qu.: -7   1st Qu.: 0.0000  
##  Median :    0   Median :    0   Median :  0   Median : 0.0000  
##  Mean   :    0   Mean   :    0   Mean   :  0   Mean   : 0.4806  
##  3rd Qu.:  310   3rd Qu.:  302   3rd Qu.:  7   3rd Qu.: 1.0000  
##  Max.   : 3860   Max.   : 3303   Max.   : 97   Max.   :10.0000  
##                                                                 
##   assistsat10        deathsat10     opp_killsat10     opp_assistsat10  
##  Min.   : 0.0000   Min.   :0.0000   Min.   : 0.0000   Min.   : 0.0000  
##  1st Qu.: 0.0000   1st Qu.:0.0000   1st Qu.: 0.0000   1st Qu.: 0.0000  
##  Median : 0.0000   Median :0.0000   Median : 0.0000   Median : 0.0000  
##  Mean   : 0.7439   Mean   :0.4825   Mean   : 0.4806   Mean   : 0.7439  
##  3rd Qu.: 1.0000   3rd Qu.:1.0000   3rd Qu.: 1.0000   3rd Qu.: 1.0000  
##  Max.   :12.0000   Max.   :7.0000   Max.   :10.0000   Max.   :12.0000  
##                                                                        
##  opp_deathsat10      goldat15         xpat15         csat15     
##  Min.   :0.0000   Min.   : 2520   Min.   :2183   Min.   :  0.0  
##  1st Qu.:0.0000   1st Qu.: 4466   1st Qu.:4961   1st Qu.: 88.0  
##  Median :0.0000   Median : 5074   Median :5955   Median :114.0  
##  Mean   :0.4825   Mean   : 4975   Mean   :5880   Mean   :100.5  
##  3rd Qu.:1.0000   3rd Qu.: 5584   3rd Qu.:7060   3rd Qu.:132.0  
##  Max.   :7.0000   Max.   :10595   Max.   :9531   Max.   :185.0  
##                                                                 
##   opp_goldat15     opp_xpat15     opp_csat15     golddiffat15     xpdiffat15   
##  Min.   : 2520   Min.   :2183   Min.   :  0.0   Min.   :-6212   Min.   :-4995  
##  1st Qu.: 4466   1st Qu.:4961   1st Qu.: 88.0   1st Qu.: -586   1st Qu.: -505  
##  Median : 5074   Median :5955   Median :114.0   Median :    0   Median :    0  
##  Mean   : 4975   Mean   :5880   Mean   :100.5   Mean   :    0   Mean   :    0  
##  3rd Qu.: 5584   3rd Qu.:7060   3rd Qu.:132.0   3rd Qu.:  586   3rd Qu.:  505  
##  Max.   :10595   Max.   :9531   Max.   :185.0   Max.   : 6212   Max.   : 4995  
##                                                                                
##    csdiffat15     killsat15        assistsat15       deathsat15    
##  Min.   :-151   Min.   : 0.0000   Min.   : 0.000   Min.   :0.0000  
##  1st Qu.: -11   1st Qu.: 0.0000   1st Qu.: 0.000   1st Qu.:0.0000  
##  Median :   0   Median : 1.0000   Median : 1.000   Median :1.0000  
##  Mean   :   0   Mean   : 0.8835   Mean   : 1.476   Mean   :0.8861  
##  3rd Qu.:  11   3rd Qu.: 1.0000   3rd Qu.: 2.000   3rd Qu.:1.0000  
##  Max.   : 151   Max.   :14.0000   Max.   :17.000   Max.   :9.0000  
##                                                                    
##  opp_killsat15     opp_assistsat15  opp_deathsat15  
##  Min.   : 0.0000   Min.   : 0.000   Min.   :0.0000  
##  1st Qu.: 0.0000   1st Qu.: 0.000   1st Qu.:0.0000  
##  Median : 1.0000   Median : 1.000   Median :1.0000  
##  Mean   : 0.8835   Mean   : 1.476   Mean   :0.8861  
##  3rd Qu.: 1.0000   3rd Qu.: 2.000   3rd Qu.:1.0000  
##  Max.   :14.0000   Max.   :17.000   Max.   :9.0000  
## 
sum(is.na(player_data))
## [1] 171895
head(which(is.na(player_data)))
## [1] 336511 336512 336513 336514 336515 336516
unique(player_data$league)
##  [1] "KeSPA"   "LPL"     "CU"      "GLL"     "BL"      "RCL"     "DL"     
##  [8] "LDL"     "LCK"     "PGN"     "UKLC"    "LCS"     "CBLOL"   "LCK CL" 
## [15] "SL"      "UL"      "PRM"     "LFL"     "NLC"     "CBLOLA"  "LCSA"   
## [22] "LVP DDH" "TRA"     "UPL"     "VCS"     "LEC"     "LJL"     "TCL"    
## [29] "OTBLX"   "EBL"     "LPLOL"   "BIG"     "BM"      "HM"      "LHE"    
## [36] "LMF"     "LLA"     "HC"      "LCL"     "PCS"     "UGP"     "LCO"    
## [43] "GSG"     "HS"      "NEXO"    "AOL"     "NERD"    "EM"      "MSI"    
## [50] "LAS"     "EGL"     "VL"      "GL"      "LJLA"    "WCS"     "CT"     
## [57] "NASG"
tier_1_leagues <- filter(player_data, league %in% c("LPL", "LCK","LEC", "LCS", "PCS", "CBLOL", "LCO", "LCL", "LJL", "LLA","TCL","VCS"))

unique(tier_1_leagues$league)
##  [1] "LPL"   "LCK"   "LCS"   "CBLOL" "VCS"   "LEC"   "LJL"   "TCL"   "LLA"  
## [10] "LCL"   "PCS"   "LCO"
player_data_tier1_leagues <- tier_1_leagues

player_data_tier1_leagues$league <- as.factor(player_data_tier1_leagues$league)
player_data_tier1_leagues %<>% select(result, everything())

player_data_tier1_leagues %>%
  select(position, `total cs`) %>%
  group_by(position) %>%
  ggplot(aes(y = `total cs`,reorder(position, `total cs`, FUN = median))) +
  geom_boxplot() +
  theme_bw() +
  ggtitle("Total CS" )

#as we can see most roles have an even spread of CS except for bot which has a large gap between progression 

player_data_tier1_leagues %>%
  select(position, cspm) %>%
  group_by(position) %>%
  ggplot(aes(y = cspm ,reorder(position, cspm, FUN = median))) +
  geom_boxplot() +
  theme_bw() +
  ggtitle("CS Per Minute" )

#cs per min Aligns with previous chart

player_data_tier1_leagues %>%
  select(position, minionkills) %>%
  group_by(position) %>%
  ggplot(aes(y = minionkills ,reorder(position, minionkills, FUN = median))) +
  geom_boxplot() +
  theme_bw() +
  ggtitle("Minion Kills" )
## Warning: Removed 20 rows containing non-finite values (stat_boxplot).

#killing minions is a standard way to get gold,the only roles that do not follow this as shown in the graph are jungle and support, 
#since both these roles earn gold in other ways this will be shown later when comparing roles

ggplot(data = player_data_tier1_leagues,  mapping = aes(x =`total cs` , y = earnedgold)) +
  geom_point(mapping = aes(color = position), alpha = .6) +
  geom_smooth() +
  theme(plot.title = element_text(family = "Helvetica", face = "bold", size = (15))) +
  ggtitle("Total Creep Score VS Earned Gold") + 
  labs(x ="Total Creep Score", y = "Earned Gold")
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'

#as we can see bot top and mid
#while we can see that while more CS does Correlate to much higher gold earned there is a disparity between support and jingle even though they both have low CS 

#top laners  
golddiff_NuguriVSFlandre <- player_data_tier1_leagues %>%
  select(playername, golddiffat15) %>%
  filter(playername == "Nuguri" | playername == "Flandre") %>%
  group_by(playername) %>%
  ggplot(mapping = aes(x = playername, y = golddiffat15, title = "Boxplot of Nuguri and Flandre Gold Differnce at 15 Minutes ")) +
  geom_boxplot(mapping = aes(fill = playername)) +
  geom_jitter(position = position_jitter(.2)) +
  coord_cartesian( ylim = c(-1500, 1500))

golddiff_NuguriVSFlandre

cspmdiff_NuguriVSFlandre <- player_data_tier1_leagues %>%
  select(playername, cspm) %>%
  filter(playername == "Nuguri" | playername == "Flandre") %>%
  group_by(playername) %>%
  ggplot(mapping = aes(x = playername, y = cspm, title = "Boxplot of Nuguri and Flandre CS")) +
  geom_boxplot(mapping = aes(fill = playername)) +
  geom_jitter(position = position_jitter(.2))


cspmdiff_NuguriVSFlandre

xpat15diff_NuguriVSFlandre <- player_data_tier1_leagues %>%
  select(playername, xpdiffat15) %>%
  filter(playername == "Nuguri" | playername == "Flandre") %>%
  group_by(playername) %>%
  ggplot(mapping = aes(x = playername, y = xpdiffat15 , title = "Boxplot of Nuguri and Flandre XP difference @15 minutes")) +
  geom_boxplot(mapping = aes(fill = playername)) +
  geom_jitter(position = position_jitter(.2))


xpat15diff_NuguriVSFlandre

plot_grid(golddiff_NuguriVSFlandre,cspmdiff_NuguriVSFlandre,xpat15diff_NuguriVSFlandre,
          labels = c("Gold Diff @ 15", "CS Diff @ 15", "XP Diff @ 15"),
          ncol = 1, nrow = 3)

#Nuguri shows a clear lead in both Average  gold and xp@15 and while both share a similar cs it is clear Nuguri is the better player
#top is a very isolated lane and this is reflected in the data by the wide range on all the stats compared to the other roles
#junglers

golddiff_TianVSJiejie <- player_data_tier1_leagues %>%
  select(playername, golddiffat15) %>%
  filter(playername == "Tian" | playername == "Jiejie") %>%
  group_by(playername) %>%
  ggplot(mapping = aes(x = playername, y = golddiffat15, title = "Boxplot of Tian and Jiejie Gold Differnce at 15 Minutes ")) +
  geom_boxplot(mapping = aes(fill = playername)) +
  geom_jitter(position = position_jitter(.2)) +
  coord_cartesian( ylim = c(-1500, 1500))

golddiff_TianVSJiejie

cspmdiff_TianVSJiejie <- player_data_tier1_leagues %>%
  select(playername, cspm) %>%
  filter(playername == "Tian" | playername == "Jiejie") %>%
  group_by(playername) %>%
  ggplot(mapping = aes(x = playername, y = cspm, title = "Boxplot of Tian and Jiejie CS")) +
  geom_boxplot(mapping = aes(fill = playername)) +
  geom_jitter(position = position_jitter(.2))


cspmdiff_TianVSJiejie

xpat15diff_TianVSJiejie <- player_data_tier1_leagues %>%
  select(playername, xpdiffat15) %>%
  filter(playername == "Tian" | playername == "Jiejie") %>%
  group_by(playername) %>%
  ggplot(mapping = aes(x = playername, y = xpdiffat15 , title = "Boxplot of Tian and Jiejie XP difference @15 minutes")) +
  geom_boxplot(mapping = aes(fill = playername)) +
  geom_jitter(position = position_jitter(.2))

#while both these players are very Similar  in most gold and xp the cs dif shows us that Tian is spending less time in jungle and more time ganking in lane 
#a much more volatile  and risky strategy with higher chance for gain but leaves the jungler more at risk of feeding the enemy team

xpat15diff_TianVSJiejie

plot_grid(golddiff_TianVSJiejie,cspmdiff_TianVSJiejie,xpat15diff_TianVSJiejie,
          labels = c("Gold Diff @ 15", "CS Diff @ 15", "XP Diff @ 15"),
          ncol = 1, nrow = 3)

#mid laners 

golddiff_DoinbVSScout <- player_data_tier1_leagues %>%
  select(playername, golddiffat15) %>%
  filter(playername == "Doinb" | playername == "Scout") %>%
  group_by(playername) %>%
  ggplot(mapping = aes(x = playername, y = golddiffat15, title = "Boxplot of Doinb and Scout Gold Differnce at 15 Minutes ")) +
  geom_boxplot(mapping = aes(fill = playername)) +
  geom_jitter(position = position_jitter(.2)) +
  coord_cartesian( ylim = c(-1500, 1500))

golddiff_DoinbVSScout

cspmdiff_DoinbVSScout <- player_data_tier1_leagues %>%
  select(playername, cspm) %>%
  filter(playername == "Doinb" | playername == "Scout") %>%
  group_by(playername) %>%
  ggplot(mapping = aes(x = playername, y = cspm, title = "Boxplot of Doinb and Scout CS")) +
  geom_boxplot(mapping = aes(fill = playername)) +
  geom_jitter(position = position_jitter(.2))


cspmdiff_DoinbVSScout

xpat15diff_DoinbVSScout <- player_data_tier1_leagues %>%
  select(playername, xpdiffat15) %>%
  filter(playername == "Doinb" | playername == "Scout") %>%
  group_by(playername) %>%
  ggplot(mapping = aes(x = playername, y = xpdiffat15 , title = "Boxplot of Doinb and Scout XP difference @15 minutes")) +
  geom_boxplot(mapping = aes(fill = playername)) +
  geom_jitter(position = position_jitter(.2))


xpat15diff_DoinbVSScout

plot_grid(golddiff_DoinbVSScout,cspmdiff_DoinbVSScout,xpat15diff_DoinbVSScout,
          labels = c("Gold Diff @ 15", "CS Diff @ 15", "XP Diff @ 15"),
          ncol = 1, nrow = 3)

#both players are even in most measure with Scout having the slight advantage in XP, 
#Mid lane tend to be passive because it grants easy Access  to all of the lane, 
#giving mid player presence to the rest of the map and other team mates Especially jungle objectives.
#bot laners 

golddiff_LwxVSViper <- player_data_tier1_leagues %>%
  select(playername, golddiffat15) %>%
  filter(playername == "Lwx" | playername == "Viper") %>%
  group_by(playername) %>%
  ggplot(mapping = aes(x = playername, y = golddiffat15, title = "Boxplot of Lwx and Viper Gold Differnce at 15 Minutes ")) +
  geom_boxplot(mapping = aes(fill = playername)) +
  geom_jitter(position = position_jitter(.2)) +
  coord_cartesian( ylim = c(-1500, 1500))

golddiff_LwxVSViper

cspmdiff_LwxVSViper <- player_data_tier1_leagues %>%
  select(playername, cspm) %>%
  filter(playername == "Lwx" | playername == "Viper") %>%
  group_by(playername) %>%
  ggplot(mapping = aes(x = playername, y = cspm, title = "Boxplot of Lwx and Viper CS")) +
  geom_boxplot(mapping = aes(fill = playername)) +
  geom_jitter(position = position_jitter(.2))


cspmdiff_LwxVSViper

xpat15diff_LwxVSViper <- player_data_tier1_leagues %>%
  select(playername, xpdiffat15) %>%
  filter(playername == "Lwx" | playername == "Viper") %>%
  group_by(playername) %>%
  ggplot(mapping = aes(x = playername, y = xpdiffat15 , title = "Boxplot of Lwx and Viper XP difference @15 minutes")) +
  geom_boxplot(mapping = aes(fill = playername)) +
  geom_jitter(position = position_jitter(.2))

xpat15diff_LwxVSViper

plot_grid(golddiff_LwxVSViper,cspmdiff_LwxVSViper,xpat15diff_LwxVSViper,
          labels = c("Gold Diff @ 15", "CS Diff @ 15", "XP Diff @ 15"),
          ncol = 1, nrow = 3)

#while viper does have more consistent  and higher gold on on avrage, while lwx is much more Sporadic ,
#this would indicate that viper plays less aggressive
#support 

golddiff_CrispVSMeiko <- player_data_tier1_leagues %>%
  select(playername, golddiffat15) %>%
  filter(playername == "Crisp" | playername == "Meiko") %>%
  group_by(playername) %>%
  ggplot(mapping = aes(x = playername, y = golddiffat15, title = "Boxplot of Crisp and Meiko Gold Differnce at 15 Minutes ")) +
  geom_boxplot(mapping = aes(fill = playername)) +
  geom_jitter(position = position_jitter(.2)) +
  coord_cartesian( ylim = c(-1500, 1500))

golddiff_CrispVSMeiko

cspmdiff_CrispVSMeiko <- player_data_tier1_leagues %>%
  select(playername, cspm) %>%
  filter(playername == "Crisp" | playername == "Meiko") %>%
  group_by(playername) %>%
  ggplot(mapping = aes(x = playername, y = cspm, title = "Boxplot of Crisp and Meiko CS")) +
  geom_boxplot(mapping = aes(fill = playername)) +
  geom_jitter(position = position_jitter(.2))


cspmdiff_CrispVSMeiko

xpat15diff_CrispVSMeiko <- player_data_tier1_leagues %>%
  select(playername, xpdiffat15) %>%
  filter(playername == "Crisp" | playername == "Meiko") %>%
  group_by(playername) %>%
  ggplot(mapping = aes(x = playername, y = xpdiffat15 , title = "Boxplot of Crisp and Meiko XP difference @15 minutes")) +
  geom_boxplot(mapping = aes(fill = playername)) +
  geom_jitter(position = position_jitter(.2))


xpat15diff_CrispVSMeiko

plot_grid(golddiff_CrispVSMeiko,cspmdiff_CrispVSMeiko,xpat15diff_CrispVSMeiko,
          labels = c("Gold Diff @ 15", "CS Diff @ 15", "XP Diff @ 15"),
          ncol = 1, nrow = 3)

##as we can see CS is not a priority for support players as they leave the CS for their bottom laner. 
#Meiko ha the clear advantage in XP diff but are relatively even in all else.
##################