Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...

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)

Registered S3 method overwritten by 'data.table':


method from
print.data.table
data.table 1.14.2 using 4 threads (see ?getDTthreads). Latest news: r-datatable.com

Hide

library(ggplot2)
library(dplyr)

Attaching package: ‘dplyr’

The following objects are masked from ‘package:data.table’:

between, first, last

The following objects are masked from ‘package:stats’:

filter, lag

The following objects are masked from ‘package:base’:

intersect, setdiff, setequal, union

Hide

library(tidyr)
library(stringr)
library(DT)

Registered S3 method overwritten by 'htmlwidgets':


method from
print.htmlwidget tools:rstudio

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)

Attaching package: ‘gridExtra’

The following object is masked from ‘package:dplyr’:

combine

Hide

library(corrplot)

corrplot 0.92 loaded

Hide

library(methods)
library(Matrix)

Attaching package: ‘Matrix’

The following objects are masked from ‘package:tidyr’:

expand, pack, unpack

Hide

library(ggthemes)
library(psych)

Attaching package: ‘psych’

The following objects are masked from ‘package:ggplot2’:

%+%, 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...

Attaching package: ‘plotly’

The following object is masked from ‘package:ggplot2’:

last_plot

The following object is masked from ‘package:stats’:

filter

The following object is masked from ‘package:graphics’:

layout

Carga Dataset

Hide

fifa <- read.csv("players_22.csv")

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

1-10 of 10 rows | 1-4 of 110 columns

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...

'data.frame': 19239 obs. of 110 variables:


$ sofifa_id : int 158023 188545 20801 190871 192985 200389 231747 167495 1
92448 202126 ...
$ player_url : chr "https://sofifa.com/player/158023/lionel-messi/220002" "
https://sofifa.com/player/188545/robert-lewandowski/220002" "https://sofifa.com/player/20801/
c-ronaldo-dos-santos-aveiro/220002" "https://sofifa.com/player/190871/neymar-da-silva-santos-
jr/220002" ...
$ short_name : chr "L. Messi" "R. Lewandowski" "Cristiano Ronaldo" "Neymar
Jr" ...
$ long_name : chr "Lionel Andrés Messi Cuccittini" "Robert Lewandowski" "
Cristiano Ronaldo dos Santos Aveiro" "Neymar da Silva Santos Júnior" ...
$ player_positions : chr "RW, ST, CF" "ST" "ST, LW" "LW, CAM" ...
$ overall : int 93 92 91 91 91 91 91 90 90 90 ...
$ potential : int 93 92 91 91 91 93 95 90 92 90 ...
$ value_eur : num 7.80e+07 1.20e+08 4.50e+07 1.29e+08 1.26e+08 ...
$ wage_eur : num 320000 270000 270000 270000 350000 130000 230000 86000 2
50000 240000 ...
$ age : int 34 32 36 29 30 28 22 35 29 27 ...
$ dob : chr "1987-06-24" "1988-08-21" "1985-02-05" "1992-02-05" ...
$ height_cm : int 170 185 187 175 181 188 182 193 187 188 ...
$ weight_kg : int 72 81 83 68 70 87 73 93 85 89 ...
$ club_team_id : num 73 21 11 73 10 240 73 21 241 18 ...
$ club_name : chr "Paris Saint-Germain" "FC Bayern München" "Manchester U
nited" "Paris Saint-Germain" ...
$ league_name : chr "French Ligue 1" "German 1. Bundesliga" "English Premier
League" "French Ligue 1" ...
$ league_level : int 1 1 1 1 1 1 1 1 1 1 ...
$ club_position : chr "RW" "ST" "ST" "LW" ...
$ club_jersey_number : int 30 9 7 10 17 13 7 1 1 10 ...
$ club_loaned_from : chr "" "" "" "" ...
$ club_joined : chr "2021-08-10" "2014-07-01" "2021-08-27" "2017-08-03" ...
$ club_contract_valid_until : int 2023 2023 2023 2025 2025 2023 2022 2023 2025 2024 ...
$ nationality_id : int 52 37 38 54 7 44 18 21 21 14 ...
$ nationality_name : chr "Argentina" "Poland" "Portugal" "Brazil" ...
$ nation_team_id : num 1369 1353 1354 NA 1325 ...
$ nation_position : chr "RW" "RS" "ST" "" ...
$ nation_jersey_number : int 10 9 7 NA 7 NA 10 1 NA 9 ...
$ preferred_foot : chr "Left" "Right" "Right" "Right" ...
$ weak_foot : int 4 4 4 5 5 3 4 4 4 5 ...
$ skill_moves : int 4 4 5 5 4 1 5 1 1 3 ...
$ international_reputation : int 5 5 5 5 4 5 4 5 4 4 ...
$ work_rate : chr "Medium/Low" "High/Medium" "High/Low" "High/Medium" ...
$ body_type : chr "Unique" "Unique" "Unique" "Unique" ...
$ real_face : chr "Yes" "Yes" "Yes" "Yes" ...
$ release_clause_eur : int 144300000 197200000 83300000 238700000 232200000 2380000
00 373500000 22300000 210400000 246100000 ...
$ player_tags : chr "#Dribbler, #Distance Shooter, #FK Specialist, #Acrobat,
#Clinical Finisher, #Complete Forward" "#Aerial Threat, #Distance Shooter, #Clinical Finishe
r, #Complete Forward" "#Aerial Threat, #Dribbler, #Distance Shooter, #Crosser, #Acrobat, #Cli
nical Finisher, #Complete Forward" "#Speedster, #Dribbler, #Playmaker, #FK Specialist, #Acrob
at, #Complete Midfielder" ...

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...

$ cf : chr "93" "88" "89" "88" ...


$ rf : chr "93" "88" "89" "88" ...
$ rw : chr "92" "85" "88" "90" ...
$ lam : chr "93" "86+3" "86+3" "89+2" ...
$ cam : chr "93" "86+3" "86+3" "89+2" ...
$ ram : chr "93" "86+3" "86+3" "89+2" ...
$ lm : chr "91+2" "84+3" "86+3" "89+2" ...
$ lcm : chr "87+3" "80+3" "78+3" "82+3" ...
$ cm : chr "87+3" "80+3" "78+3" "82+3" ...
$ rcm : chr "87+3" "80+3" "78+3" "82+3" ...
$ rm : chr "91+2" "84+3" "86+3" "89+2" ...
$ lwb : chr "66+3" "64+3" "63+3" "67+3" ...
$ ldm : chr "64+3" "66+3" "59+3" "63+3" ...
$ cdm : chr "64+3" "66+3" "59+3" "63+3" ...
$ rdm : chr "64+3" "66+3" "59+3" "63+3" ...
$ rwb : chr "66+3" "64+3" "63+3" "67+3" ...
[list output truncated]

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...

sofifa_id player_url short_name long_name player_positions


overall
Min. : 41 Length:19239 Length:19239 Length:19239 Length:19239
Min. :47.00
1st Qu.:214414 Class :character Class :character Class :character Class :character
1st Qu.:61.00
Median :236543 Mode :character Mode :character Mode :character Mode :character
Median :66.00
Mean :231468
Mean :65.77
3rd Qu.:253533
3rd Qu.:70.00
Max. :264640
Max. :93.00

potential value_eur wage_eur age dob hei


ght_cm
Min. :49.00 Min. :9.00e+03 Min. : 500 Min. :16.00 Length:19239 Min.
:155.0
1st Qu.:67.00 1st Qu.:4.75e+05 1st Qu.: 1000 1st Qu.:21.00 Class :character 1st Q
u.:176.0
Median :71.00 Median :9.75e+05 Median : 3000 Median :25.00 Mode :character Media
n :181.0
Mean :71.08 Mean :2.85e+06 Mean : 9018 Mean :25.21 Mean
:181.3
3rd Qu.:75.00 3rd Qu.:2.00e+06 3rd Qu.: 8000 3rd Qu.:29.00 3rd Q
u.:186.0
Max. :95.00 Max. :1.94e+08 Max. :350000 Max. :54.00 Max.
:206.0
NA's :74 NA's :61
weight_kg club_team_id club_name league_name league_level club
_position
Min. : 49.00 Min. : 1 Length:19239 Length:19239 Min. :1.000 Leng
th:19239
1st Qu.: 70.00 1st Qu.: 479 Class :character Class :character 1st Qu.:1.000 Clas
s :character
Median : 75.00 Median : 1938 Mode :character Mode :character Median :1.000 Mode
:character
Mean : 74.94 Mean : 50581 Mean :1.354
3rd Qu.: 80.00 3rd Qu.:111139 3rd Qu.:1.000
Max. :110.00 Max. :115820 Max. :5.000
NA's :61 NA's :61
club_jersey_number club_loaned_from club_joined club_contract_valid_until nationali
ty_id
Min. : 1.00 Length:19239 Length:19239 Min. :2021 Min. :
1.0
1st Qu.: 9.00 Class :character Class :character 1st Qu.:2022 1st Qu.:
21.0
Median :18.00 Mode :character Mode :character Median :2022 Median :
45.0
Mean :20.95 Mean :2023 Mean :

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

release_clause_eur player_tags player_traits pace shooting


passing
Min. : 16000 Length:19239 Length:19239 Min. :28.00 Min. :18.00 Mi
n. :25.00
1st Qu.: 806000 Class :character Class :character 1st Qu.:62.00 1st Qu.:42.00 1s
t Qu.:51.00
Median : 1600000 Mode :character Mode :character Median :69.00 Median :54.00 Me
dian :58.00
Mean : 5374044 Mean :68.21 Mean :52.35 Me
an :57.31
3rd Qu.: 3700000 3rd Qu.:76.00 3rd Qu.:63.00 3r
d Qu.:64.00
Max. :373500000 Max. :97.00 Max. :94.00 Ma
x. :93.00
NA's :1176 NA's :2132 NA's :2132 NA
's :2132
dribbling defending physic attacking_crossing attacking_finishing
Min. :27.00 Min. :14.0 Min. :29.00 Min. : 6.00 Min. : 2.00
1st Qu.:57.00 1st Qu.:37.0 1st Qu.:59.00 1st Qu.:38.00 1st Qu.:30.00
Median :64.00 Median :56.0 Median :66.00 Median :54.00 Median :50.00

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

skill_fk_accuracy skill_long_passing skill_ball_control movement_acceleration movement_sprin


t_speed
Min. : 4.00 Min. : 9.00 Min. : 8.00 Min. :14.00 Min. :15.00
1st Qu.:31.00 1st Qu.:44.00 1st Qu.:55.00 1st Qu.:57.00 1st Qu.:58.00
Median :41.00 Median :56.00 Median :63.00 Median :67.00 Median :68.00
Mean :42.25 Mean :53.07 Mean :58.47 Mean :64.65 Mean :64.71
3rd Qu.:55.00 3rd Qu.:64.00 3rd Qu.:69.00 3rd Qu.:75.00 3rd Qu.:75.00
Max. :94.00 Max. :93.00 Max. :96.00 Max. :97.00 Max. :97.00

movement_agility movement_reactions movement_balance power_shot_power power_jumping power_


stamina
Min. :18.0 Min. :25.00 Min. :15.00 Min. :20.00 Min. :22.00 Min.
:12.00
1st Qu.:55.0 1st Qu.:56.00 1st Qu.:56.00 1st Qu.:48.00 1st Qu.:57.00 1st Q
u.:56.00
Median :66.0 Median :62.00 Median :66.00 Median :59.00 Median :65.00 Median
:66.00
Mean :63.5 Mean :61.45 Mean :64.07 Mean :57.78 Mean :64.81 Mean
:63.08
3rd Qu.:74.0 3rd Qu.:67.00 3rd Qu.:74.00 3rd Qu.:68.00 3rd Qu.:73.00 3rd Q
u.:74.00
Max. :96.0 Max. :94.00 Max. :96.00 Max. :95.00 Max. :95.00 Max.
:97.00

power_strength power_long_shots mentality_aggression mentality_interceptions mentality_posi


tioning
Min. :19.00 Min. : 4.00 Min. :10.00 Min. : 3.00 Min. : 2.00
1st Qu.:57.00 1st Qu.:32.00 1st Qu.:44.00 1st Qu.:26.00 1st Qu.:40.00
Median :66.00 Median :51.00 Median :58.00 Median :53.00 Median :56.00
Mean :65.01 Mean :46.64 Mean :55.54 Mean :46.61 Mean :50.33
3rd Qu.:74.00 3rd Qu.:62.00 3rd Qu.:68.00 3rd Qu.:64.00 3rd Qu.:64.00
Max. :97.00 Max. :94.00 Max. :95.00 Max. :91.00 Max. :96.00

10 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...

mentality_vision mentality_penalties mentality_composure defending_marking_awareness defendi


ng_standing_tackle
Min. :10.00 Min. : 7.00 Min. :12.00 Min. : 4.0 Min.
: 5.00
1st Qu.:45.00 1st Qu.:38.00 1st Qu.:50.00 1st Qu.:29.0 1st Q
u.:28.00
Median :55.00 Median :49.00 Median :59.00 Median :52.0 Median
:56.00
Mean :53.96 Mean :47.86 Mean :57.93 Mean :46.6 Mean
:48.05
3rd Qu.:64.00 3rd Qu.:60.00 3rd Qu.:66.00 3rd Qu.:63.0 3rd Q
u.:65.00
Max. :95.00 Max. :93.00 Max. :96.00 Max. :93.0 Max.
:93.00

defending_sliding_tackle goalkeeping_diving goalkeeping_handling goalkeeping_kicking goalkee


ping_positioning
Min. : 5.00 Min. : 2.00 Min. : 2.00 Min. : 2.00 Min.
: 2.00
1st Qu.:25.00 1st Qu.: 8.00 1st Qu.: 8.00 1st Qu.: 8.00 1st Q
u.: 8.00
Median :53.00 Median :11.00 Median :11.00 Median :11.00 Median
:11.00
Mean :45.91 Mean :16.41 Mean :16.19 Mean :16.06 Mean
:16.23
3rd Qu.:63.00 3rd Qu.:14.00 3rd Qu.:14.00 3rd Qu.:14.00 3rd Q
u.:14.00
Max. :92.00 Max. :91.00 Max. :92.00 Max. :93.00 Max.
:92.00

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

lam cam ram lm lcm


Length:19239 Length:19239 Length:19239 Length:19239 Length:19239

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

cm rcm rm lwb ldm


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

cdm rdm rwb lb lcb


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

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

club_logo_url club_flag_url nation_logo_url nation_flag_url


Length:19239 Length:19239 Length:19239 Length:19239
Class :character Class :character Class :character Class :character
Mode :character Mode :character Mode :character Mode :character

Conversión de Vairables tipo Caracter a Factor

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

Seleccionar variables relevantes e importantes para la estadísticas descriptivas

Hide

fifaInfo <- select(fifa, age, overall, potential, value_eur, international_reputation, nation


ality_name, pace, shooting, passing, dribbling, defending, physic)

Uso de option() para se deslieguen número con notación científica

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

describe(fifaInfo, na.rm = TRUE, interp=FALSE,skew = FALSE, ranges = TRUE,trim=.1,


type=3,check=TRUE,fast=TRUE,quant=NULL,IQR=FALSE)

Warning in FUN(newX[, i], ...) :


no non-missing arguments to min; returning Inf
Warning in FUN(newX[, i], ...) :
no non-missing arguments to max; returning -Inf

v… n mean sd min max range


<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>

age 1 19239 25.2 4.75 16 54 38

overall 2 19239 65.8 6.88 47 93 46

potential 3 19239 71.1 6.09 49 95 46

value_eur 4 19165 2850451.8 7613699.95 9000 194000000 193991000 54997.30

international_reputation 5 19239 1.1 0.37 1 5 4

nationality_name 6 19239 NaN NA Inf -Inf -Inf

pace 7 17107 68.2 10.93 28 97 69

shooting 8 17107 52.4 14.05 18 94 76

passing 9 17107 57.3 10.07 25 93 68

13 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...

v… n mean sd min max range


<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>

dribbling 10 17107 62.6 9.65 27 95 68

1-10 of 12 rows Previous 1 2 Next

Hide

ClubStat <- describeBy(fifaInfo, fifaInfo$nationality_name)

Warning in FUN(newX[, i], ...) :


no non-missing arguments to min; returning Inf
Warning in FUN(newX[, i], ...) :
no non-missing arguments to min; returning Inf
Warning in FUN(newX[, i], ...) :
no non-missing arguments to min; returning Inf
Warning in FUN(newX[, i], ...) :
no non-missing arguments to min; returning Inf
Warning in FUN(newX[, i], ...) :
no non-missing arguments to min; returning Inf
Warning in FUN(newX[, i], ...) :
no non-missing arguments to min; returning Inf
Warning in FUN(newX[, i], ...) :
no non-missing arguments to max; returning -Inf
Warning in FUN(newX[, i], ...) :
no non-missing arguments to max; returning -Inf
Warning in FUN(newX[, i], ...) :
no non-missing arguments to max; returning -Inf
Warning in FUN(newX[, i], ...) :
no non-missing arguments to max; returning -Inf
Warning in FUN(newX[, i], ...) :
no non-missing arguments to max; returning -Inf
Warning in FUN(newX[, i], ...) :
no non-missing arguments to max; returning -Inf

Estadistica descriptiva para el top 5 de equipos a nivel mundial.

Hide

ClubStat["Argentina"]

$Argentina

v… n mean sd median trimm… mad min


<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>

age 1 960 26.5 5.2 26 26 5.9 16

overall 2 960 68.7 5.4 69 69 5.9 55

14 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...

v… n mean sd median trimm… mad min


<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>

potential 3 960 73.1 5.1 73 73 4.4 58

value_eur 4 956 3272055.4 7042172.3 1500000 1861815 1186080.0 45000

international_reputation 5 960 1.1 0.4 1 1 0.0 1

nationality_name* 6 960 7.0 0.0 7 7 0.0 7

pace 7 864 68.1 11.2 69 69 10.4 31

shooting 8 864 56.2 13.6 59 57 13.3 23

passing 9 864 60.2 9.4 61 60 8.9 29

dribbling 10 864 65.7 9.1 67 66 7.4 31

1-10 of 12 rows | 1-10 of 13 columns Previous 1 2 Next

NA

Hide

ClubStat["France"]

$France

v… n mean sd median trimmed mad


<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>

age 1 980 24.5 4.68 24 24.1 4.4

overall 2 980 67.5 6.84 67 67.3 7.4

potential 3 980 73.4 5.90 73 73.2 5.9

value_eur 4 980 4698387.8 11533885.97 1300000 2081154.3 1186080.0

international_reputation 5 980 1.2 0.52 1 1.1 0.0

nationality_name* 6 980 57.0 0.00 57 57.0 0.0

pace 7 883 67.5 11.45 68 68.1 10.4

shooting 8 883 52.7 14.22 55 53.0 14.8

passing 9 883 59.5 10.05 60 59.8 10.4

dribbling 10 883 64.7 9.58 66 65.2 8.9

1-10 of 12 rows | 1-9 of 13 columns Previous 1 2 Next

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

v… n mean sd median trimm… mad


<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>

age 1 373 25.1 4.54 25 25 4.4

overall 2 373 69.7 6.30 69 69 5.9

potential 3 373 75.0 5.67 74 75 5.9

value_eur 4 373 6086689.0 12820026.24 1900000 3059030 1704990.0 130000

international_reputation 5 373 1.2 0.56 1 1 0.0

nationality_name* 6 373 125.0 0.00 125 125 0.0

pace 7 335 69.4 11.12 70 70 10.4

shooting 8 335 55.7 14.44 59 56 14.8

passing 9 335 61.6 10.45 62 62 10.4

dribbling 10 335 67.5 10.00 68 68 8.9

1-10 of 12 rows | 1-9 of 13 columns Previous 1 2 Next

NA

Hide

ClubStat["Brazil"]

$Brazil

v… n mean sd median trimm… mad


<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>

age 1 897 26.4 4.07 26 26 4.4

overall 2 897 70.8 5.30 71 71 4.4

potential 3 897 73.0 5.32 72 73 4.4

value_eur 4 897 5102982.2 10419589.24 1900000 2724618 1519665.0 120000

international_reputation 5 897 1.1 0.43 1 1 0.0

nationality_name* 6 897 21.0 0.00 21 21 0.0

16 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...

v… n mean sd median trimm… mad


<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>

pace 7 827 69.7 11.15 71 70 10.4

shooting 8 827 57.9 13.15 61 59 13.3

passing 9 827 61.7 9.29 62 62 8.9

dribbling 10 827 66.8 9.41 68 68 7.4

1-10 of 12 rows | 1-9 of 13 columns Previous 1 2 Next

NA

Hide

ClubStat["Italy"]

$Italy

v… n mean sd median trimmed mad


<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>

age 1 338 26.3 4.78 26 26.1 5.9

overall 2 338 70.0 6.98 70 70.0 7.4

potential 3 338 74.4 6.11 74 74.3 5.9

value_eur 4 338 6320961.5 13002916.53 1850000 3239246.3 1853250.0

international_reputation 5 338 1.4 0.63 1 1.2 0.0

nationality_name* 6 338 81.0 0.00 81 81.0 0.0

pace 7 287 67.4 10.24 67 67.6 8.9

shooting 8 287 55.0 15.32 58 55.6 16.3

passing 9 287 60.7 11.51 61 61.2 11.9

dribbling 10 287 66.6 10.15 67 67.2 8.9

1-10 of 12 rows | 1-9 of 13 columns Previous 1 2 Next

NA

Hide

17 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...

Top5 <- c("Argentina","France","Portugal","Brazil","Italy")


Top5Club <- filter(fifa,nationality_name %in% Top5)

bp1 <- Top5Club %>%


mutate(nationality_name = fct_reorder(nationality_name, desc(overall))) %>%
ggplot(aes(nationality_name, y=overall))+
geom_boxplot()+
theme(axis.text.x = element_text(angle = 45, hjust = 1))

bp1

Hide

bp2 <- Top5Club %>%


mutate(nationality_name = fct_reorder(nationality_name, desc(wage_eur))) %>%
ggplot(aes(nationality_name, y=wage_eur))+
geom_boxplot()+
theme(axis.text.x = element_text(angle = 45, hjust = 1))

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 <- Top5Club %>%


mutate(nationality_name = fct_reorder(nationality_name, desc(potential))) %>%
ggplot(aes(nationality_name, y=potential))+
geom_boxplot()+
theme(axis.text.x = element_text(angle = 45, hjust = 1))

bp3

19 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...

Hide

Age_sq <- mutate(fifa, Age_sq = age^2)

ScatterAge <- ggplot(data = fifa, aes(age,value_eur)) +


geom_point() +
labs(x='Age',y='Value',title='Value v.s. Age')

ScatterAge

Warning: Removed 74 rows containing missing values (geom_point).

20 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...

Hide

ScatterOverall <- ggplot(data = fifa, aes(overall,value_eur)) +


geom_point() +
labs(x='Overall',y='Value',title='Value v.s. Overall Score') +
geom_smooth()

ScatterOverall

`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'


Warning: Removed 74 rows containing non-finite values (stat_smooth).
Warning: Removed 74 rows containing missing values (geom_point).

21 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...

Hide

ScatterPotential <- ggplot(data = fifa, aes(potential,value_eur)) +


geom_point() +
labs(x='Potential',y='Value',title='Value v.s. Potential Score') +
geom_smooth()

ScatterPotential

`geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'


Warning: Removed 74 rows containing non-finite values (stat_smooth).
Warning: Removed 74 rows containing missing values (geom_point).

22 de 24 28/4/2022 22:09
R Notebook file:///G:/My%20Drive/Master/4_trimestre/Analisis_de_datos/FIFA/Proy...

Hide

ScatterWage <- ggplot(data = fifa, aes(wage_eur,value_eur)) +


geom_point() +
labs(x='Wage',y='Value',title='Value v.s. Wage') +
geom_abline()
ScatterWage

Warning: Removed 74 rows containing missing values (geom_point).

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

You might also like