Professional Documents
Culture Documents
R Notebook FIFA
R Notebook FIFA
R Notebook
Code
This is an R Markdown (http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook,
the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and
pressing Ctrl+Shift+Enter.
Carga de Librerías
Hide
library(data.table)
Hide
library(ggplot2)
library(dplyr)
filter, lag
Hide
library(tidyr)
library(stringr)
library(DT)
1 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
Hide
library(knitr)
library(grid)
library(gridExtra)
combine
Hide
library(corrplot)
Hide
library(methods)
library(Matrix)
Hide
library(ggthemes)
library(psych)
%+%, alpha
Hide
library(forcats)
library(plotly)
2 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
last_plot
filter
layout
Carga Dataset
Hide
Exploración de Datos
Hide
class(fifa)
[1] "data.frame"
Hide
head(fifa, 10)
sofifa_id player_url
<int> <chr>
1 158023 https://sofifa.com/player/158023/lionel-messi/220002
2 188545 https://sofifa.com/player/188545/robert-lewandowski/220002
3 20801 https://sofifa.com/player/20801/c-ronaldo-dos-santos-aveiro/220002
4 190871 https://sofifa.com/player/190871/neymar-da-silva-santos-jr/220002
5 192985 https://sofifa.com/player/192985/kevin-de-bruyne/220002
6 200389 https://sofifa.com/player/200389/jan-oblak/220002
7 231747 https://sofifa.com/player/231747/kylian-mbappe/220002
8 167495 https://sofifa.com/player/167495/manuel-neuer/220002
3 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
sofifa_id player_url
<int> <chr>
9 192448 https://sofifa.com/player/192448/marc-andre-ter-stegen/220002
10 202126 https://sofifa.com/player/202126/harry-kane/220002
Hide
str(fifa)
4 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
5 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
$ player_traits : chr "Finesse Shot, Long Shot Taker (AI), Playmaker (AI), Out
side Foot Shot, One Club Player, Chip Shot (AI), Technic"| __truncated__ "Solid Player, Fines
se Shot, Outside Foot Shot, Chip Shot (AI)" "Power Free-Kick, Flair, Long Shot Taker (AI), Sp
eed Dribbler (AI), Outside Foot Shot" "Injury Prone, Flair, Speed Dribbler (AI), Playmaker (A
I), Outside Foot Shot, Technical Dribbler (AI)" ...
$ pace : int 85 78 87 91 76 NA 97 NA NA 70 ...
$ shooting : int 92 92 94 83 86 NA 88 NA NA 91 ...
$ passing : int 91 79 80 86 93 NA 80 NA NA 83 ...
$ dribbling : int 95 86 88 94 88 NA 92 NA NA 83 ...
$ defending : int 34 44 34 37 64 NA 36 NA NA 47 ...
$ physic : int 65 82 75 63 78 NA 77 NA NA 83 ...
$ attacking_crossing : int 85 71 87 85 94 13 78 15 18 80 ...
$ attacking_finishing : int 95 95 95 83 82 11 93 13 14 94 ...
$ attacking_heading_accuracy : int 70 90 90 63 55 15 72 25 11 86 ...
$ attacking_short_passing : int 91 85 80 86 94 43 85 60 61 85 ...
$ attacking_volleys : int 88 89 86 86 82 13 83 11 14 88 ...
$ skill_dribbling : int 96 85 88 95 88 12 93 30 21 83 ...
$ skill_curve : int 93 79 81 88 85 13 80 14 18 83 ...
$ skill_fk_accuracy : int 94 85 84 87 83 14 69 11 12 65 ...
$ skill_long_passing : int 91 70 77 81 93 40 71 68 63 86 ...
$ skill_ball_control : int 96 88 88 95 91 30 91 46 30 85 ...
$ movement_acceleration : int 91 77 85 93 76 43 97 54 38 65 ...
$ movement_sprint_speed : int 80 79 88 89 76 60 97 60 50 74 ...
$ movement_agility : int 91 77 86 96 79 67 92 51 39 71 ...
$ movement_reactions : int 94 93 94 89 91 88 93 87 86 92 ...
$ movement_balance : int 95 82 74 84 78 49 83 35 43 70 ...
$ power_shot_power : int 86 90 94 80 91 59 86 68 66 91 ...
$ power_jumping : int 68 85 95 64 63 78 78 77 79 79 ...
$ power_stamina : int 72 76 77 81 89 41 88 43 35 83 ...
$ power_strength : int 69 86 77 53 74 78 77 80 78 85 ...
$ power_long_shots : int 94 87 93 81 91 12 82 16 10 86 ...
$ mentality_aggression : int 44 81 63 63 76 34 62 29 43 80 ...
$ mentality_interceptions : int 40 49 29 37 66 19 38 30 22 44 ...
$ mentality_positioning : int 93 95 95 86 88 11 92 12 11 94 ...
$ mentality_vision : int 95 81 76 90 94 65 82 70 70 87 ...
$ mentality_penalties : int 75 90 88 93 83 11 79 47 25 91 ...
$ mentality_composure : int 96 88 95 93 89 68 88 70 70 91 ...
$ defending_marking_awareness: int 20 35 24 35 68 27 26 17 25 50 ...
$ defending_standing_tackle : int 35 42 32 32 65 12 34 10 13 36 ...
$ defending_sliding_tackle : int 24 19 24 29 53 18 32 11 10 38 ...
$ goalkeeping_diving : int 6 15 7 9 15 87 13 88 88 8 ...
$ goalkeeping_handling : int 11 6 11 9 13 92 5 88 85 10 ...
$ goalkeeping_kicking : int 15 12 15 15 5 78 7 91 88 11 ...
$ goalkeeping_positioning : int 14 8 14 15 10 90 11 89 88 14 ...
$ goalkeeping_reflexes : int 8 10 11 11 13 90 6 88 90 11 ...
$ goalkeeping_speed : int NA NA NA NA NA 50 NA 56 43 NA ...
$ ls : chr "89+3" "90+2" "90+1" "83+3" ...
$ st : chr "89+3" "90+2" "90+1" "83+3" ...
$ rs : chr "89+3" "90+2" "90+1" "83+3" ...
$ lw : chr "92" "85" "88" "90" ...
$ lf : chr "93" "88" "89" "88" ...
6 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
Hide
summary(fifa)
7 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
8 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
58.6
3rd Qu.:27.00 3rd Qu.:2024 3rd Qu.:
60.0
Max. :99.00 Max. :2031 Max. :2
19.0
NA's :61 NA's :61
nationality_name nation_team_id nation_position nation_jersey_number preferred_foot
weak_foot
Length:19239 Min. : 1318 Length:19239 Min. : 1.00 Length:19239
Min. :1.000
Class :character 1st Qu.: 1338 Class :character 1st Qu.: 7.00 Class :character
1st Qu.:3.000
Mode :character Median : 1357 Mode :character Median :12.00 Mode :character
Median :3.000
Mean : 14481 Mean :12.57
Mean :2.946
3rd Qu.: 1386 3rd Qu.:19.00
3rd Qu.:3.000
Max. :111473 Max. :28.00
Max. :5.000
NA's :18480 NA's :18480
skill_moves international_reputation work_rate body_type real_face
Min. :1.000 Min. :1.000 Length:19239 Length:19239 Length:19239
1st Qu.:2.000 1st Qu.:1.000 Class :character Class :character Class :charac
ter
Median :2.000 Median :1.000 Mode :character Mode :character Mode :charac
ter
Mean :2.352 Mean :1.094
3rd Qu.:3.000 3rd Qu.:1.000
Max. :5.000 Max. :5.000
9 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
Mean :62.56 Mean :51.7 Mean :64.82 Mean :49.58 Mean :45.89
3rd Qu.:69.00 3rd Qu.:64.0 3rd Qu.:72.00 3rd Qu.:63.00 3rd Qu.:62.00
Max. :95.00 Max. :91.0 Max. :90.00 Max. :94.00 Max. :95.00
NA's :2132 NA's :2132 NA's :2132
attacking_heading_accuracy attacking_short_passing attacking_volleys skill_dribbling skill_
curve
Min. : 5.00 Min. : 7.00 Min. : 3.00 Min. : 4.00 Min.
: 6.00
1st Qu.:44.00 1st Qu.:54.00 1st Qu.:30.00 1st Qu.:50.00 1st Q
u.:35.00
Median :55.00 Median :62.00 Median :43.00 Median :61.00 Median
:49.00
Mean :51.78 Mean :58.87 Mean :42.46 Mean :55.66 Mean
:47.27
3rd Qu.:64.00 3rd Qu.:68.00 3rd Qu.:56.00 3rd Qu.:68.00 3rd Q
u.:61.00
Max. :93.00 Max. :94.00 Max. :90.00 Max. :96.00 Max.
:94.00
10 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
goalkeeping_reflexes goalkeeping_speed ls st rs
Min. : 2.00 Min. :15.00 Length:19239 Length:19239 Length:19239
1st Qu.: 8.00 1st Qu.:27.00 Class :character Class :character Class :characte
r
Median :11.00 Median :36.00 Mode :character Mode :character Mode :characte
r
Mean :16.49 Mean :36.44
3rd Qu.:14.00 3rd Qu.:45.00
Max. :90.00 Max. :65.00
NA's :17107
lw lf cf rf rw
Length:19239 Length:19239 Length:19239 Length:19239 Length:19239
Class :character Class :character Class :character Class :character Class :character
Mode :character Mode :character Mode :character Mode :character Mode :character
11 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
Class :character Class :character Class :character Class :character Class :character
Mode :character Mode :character Mode :character Mode :character Mode :character
cb rcb rb gk player_face_url
Length:19239 Length:19239 Length:19239 Length:19239 Length:19239
Class :character Class :character Class :character Class :character Class :character
Mode :character Mode :character Mode :character Mode :character Mode :character
Hide
fifa$nationality_name = factor(fifa$nationality_name)
Chequear valores NA
Hide
12 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
sum(is.na(fifa))
[1] 68414
Hide
Hide
options(scipen = 999)
options(digits = 2)
Demostrar el mínimo, máximo y promedio (media, mediana, moda) y desviación estándar / varianza de
variables importantes.
Hide
13 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
Hide
Hide
ClubStat["Argentina"]
$Argentina
14 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
NA
Hide
ClubStat["France"]
$France
NA
15 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
Hide
ClubStat["Portugal"]
$Portugal
NA
Hide
ClubStat["Brazil"]
$Brazil
16 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
NA
Hide
ClubStat["Italy"]
$Italy
NA
Hide
17 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
bp1
Hide
bp2
18 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
Hide
bp3
19 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
Hide
ScatterAge
20 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
Hide
ScatterOverall
21 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
Hide
ScatterPotential
22 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
Hide
23 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the
Preview button or press Ctrl+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview
does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.
24 de 24 28/4/2022 22:09