Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GMTool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
margarr
GMTool
Commits
1b3f5794
Commit
1b3f5794
authored
May 29, 2022
by
Mario Garrido Tapias
Browse files
Options
Downloads
Patches
Plain Diff
All variables contemplated
parent
e41842cd
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
BivariateAnalysis.R
+60
-16
60 additions, 16 deletions
BivariateAnalysis.R
with
60 additions
and
16 deletions
BivariateAnalysis.R
+
60
−
16
View file @
1b3f5794
...
...
@@ -3,6 +3,24 @@ setwd("/home/mariogt/TFGs/Estadistica/")
#####################################
# FUNCIONES #
#####################################
puntos2d
<-
function
(
variableEnX
,
variableEnY
,
datos
,
temporada
,
color
)
{
# Variables AUXILIARES
maxX
<-
which.max
(
eval
(
parse
(
text
=
paste
(
"datos$"
,
variableEnX
,
"."
,
temporada
,
sep
=
""
))))
maxY
<-
which.max
(
eval
(
parse
(
text
=
paste
(
"datos$"
,
variableEnY
,
"."
,
temporada
,
sep
=
""
))))
xMean
<-
mean
(
eval
(
parse
(
text
=
paste
(
"datos$"
,
variableEnX
,
"."
,
temporada
,
sep
=
""
))))
ggplot
(
datos
,
aes
(
eval
(
parse
(
text
=
paste
(
variableEnX
,
"."
,
temporada
,
sep
=
""
))),
eval
(
parse
(
text
=
paste
(
variableEnY
,
"."
,
temporada
,
sep
=
""
)))))
+
labs
(
x
=
titleForYAxis
(
variableEnX
),
y
=
titleForYAxis
(
variableEnY
))
+
geom_point
(
colour
=
color
)
+
geom_label_repel
(
data
=
subset
(
datos
,
eval
(
parse
(
text
=
paste
(
variableEnX
,
"."
,
temporada
,
sep
=
""
)))
>
eval
(
parse
(
text
=
paste
(
variableEnX
,
"."
,
temporada
,
"["
,
maxX
,
"]"
,
sep
=
""
)))
-
xMean
),
aes
(
label
=
player
),
box.padding
=
0.35
,
point.padding
=
0.5
,
segment.color
=
'grey50'
)
}
#############
# LIBRERIAS #
...
...
@@ -10,31 +28,57 @@ setwd("/home/mariogt/TFGs/Estadistica/")
library
(
dplyr
)
library
(
ggplot2
)
library
(
ggcorrplot
)
# Correlation matrix visualization
library
(
correlation
)
# Correlation matrix table
library
(
RColorBrewer
)
library
(
yarrr
)
library
(
ggrepel
)
library
(
PerformanceAnalytics
)
# Seleccion de las varibles de ESTUDIO
variables
<-
paste
(
c
(
"age."
,
"height."
,
"goals_assists_per90."
,
"xg."
,
"npxg."
,
"xa."
,
"shots_on_target_pct."
,
"passes_pct."
,
"assisted_shots."
,
"passes_switches."
,
"sca_passes_dead."
,
"gca_passes_dead."
,
"passes_intercepted."
,
"pressure_regains."
,
"dribbles_completed_pct."
,
"fouls."
,
"ball_recoveries."
,
"aerials_won_pct."
,
"pens_att."
,
"goals_against_per90_gk."
,
"save_pct."
),
"1718"
,
sep
=
""
)
#
variables <- paste(c("age.", "height.", "goals_assists_per90.", "xg.", "npxg.", "xa.", "shots_on_target_pct.", "passes_pct.",
#
"assisted_shots.", "passes_switches.", "sca_passes_dead.", "gca_passes_dead.", "passes_intercepted.",
#
"pressure_regains.", "dribbles_completed_pct.", "fouls.", "ball_recoveries.", "aerials_won_pct.",
#
"pens_att.", "goals_against_per90_gk.", "save_pct."), "1718", sep = "")
# variables <- paste(c("age.", "height.", "goals_assists_per90.", "xg.", "npxg.", "xa.", "shots_on_target_pct.", "passes_pct.",
# "assisted_shots.", "passes_switches.", "sca_passes_dead.", "gca_passes_dead.", "passes_intercepted.",
# "pressure_regains.", "dribbles_completed_pct.", "fouls.", "ball_recoveries.", "aerials_won_pct.",
# "pens_att.", "goals_against_per90_gk.", "save_pct.", "passes_received_pct.", "goals_per_shot.", "passes_pressure."), "1718", sep = "")
variables
<-
paste
(
c
(
"age."
,
"height."
,
"goals_assists_per90."
,
"xg."
,
"npxg."
,
"xa."
,
"shots_on_target_pct."
,
"passes_pct."
,
"
assisted_shot
s."
,
"passes_
switches
."
,
"
sca_
passes_
dead."
,
"gca_passes_dead
."
,
"passes_
intercepted
."
,
"p
ressure_regains."
,
"dribbles_completed_pct."
,
"fouls."
,
"ball_recoveries."
,
"aerials_won_pct
."
,
"
pens_att."
,
"goals_against_per90_gk."
,
"save_pc
t."
,
"
sca_passes_live."
,
"gca_passes_live
."
,
"
sca_
dribbles."
,
"
gca_
dribbles
."
,
"sca_fouled."
,
"gca_fouled."
),
"1718"
,
sep
=
""
)
trainStudy
<-
train
%>%
select
(
contains
(
va
ri
a
bles
))
trainStudy
<-
(
trainStudy
)
trainStudy
<-
data.frame
(
lapply
(
trainStudy
,
as.numeric
)
)
variables
<-
paste
(
c
(
"age."
,
"height."
,
"
xa."
,
"passes_completed."
,
"passe
s."
,
"passes_
pct
."
,
"passes_
total_distance."
,
"assisted_shots
."
,
"passes_
switches
."
,
"p
ass_targets."
,
"passes_received."
,
"passes_received_pct."
,
"passes_pressure
."
,
"
xg."
,
"npxg."
,
"shots_total."
,
"shots_on_target."
,
"shots_on_target_pct."
,
"goals_per_shot."
,
"pens_made."
,
"pens_at
t."
,
"
dribbles
."
,
"dribbles
_completed
."
,
"dribbles
_completed_pct."
,
"goals_assists_per90."
,
"sca_passes_dead."
,
"gca_passes_dead."
,
"sca_passes_live."
,
"gca_passes_live."
,
"sca_dribbles."
,
"gca_d
ri
b
bles
."
,
"sca_fouled."
,
"gca_fouled."
,
"passes_intercepted."
,
"ball_recoveries."
,
"pressure_regains."
,
"fouls."
,
"tackles_won"
,
"tackles"
,
"aerials_won."
,
"aerials_lost."
,
"aerials_won_pct."
,
"goals_against_per90_gk."
,
"pens_saved."
,
"pens_allowed."
,
"shots_on_target_against."
,
"saves."
,
"save_pct."
),
"1718"
,
sep
=
""
)
correlacion
<-
round
(
cor
(
trainStudy
),
1
)
p.mat
<-
cor_pmat
(
trainStudy
)
trainStudy
<-
train
%>%
select
(
starts_with
(
variables
))
trainStudy
<-
data.frame
(
lapply
(
trainStudy
,
as.numeric
))
trainStudyStand
<-
as.data.frame
(
scale
(
trainStudy
))
correlacion
<-
round
(
cor
(
trainStudyStand
),
1
)
p.mat
<-
cor_pmat
(
trainStudyStand
)
mypalette
<-
brewer.pal
(
n
=
3
,
name
=
'BuPu'
)
ggcorrplot
(
correlacion
,
type
=
"upper"
,
title
=
"Matriz de correlaciones ordenada"
,
hc.order
=
TRU
E
,
lab
=
TRUE
,
pch.cex
=
1.2
,
lab_size
=
2.5
,
hc.order
=
FALS
E
,
lab
=
TRUE
,
pch.cex
=
1.2
,
lab_size
=
2.5
,
tl.cex
=
9
,
colors
=
mypalette
,
ggtheme
=
ggplot2
::
theme_gray
,
p.mat
=
p.mat
,
insig
=
"blank"
)
correlation
::
correlation
(
trainStudyStand
,
include_factors
=
TRUE
,
method
=
"pearson"
)
# Porcentaje SI/NO
passes
<-
trainStudy
[,
4
:
6
]
chart.Correlation
(
passes
,
histogram
=
TRUE
,
pch
=
18
)
#######################
# ANALISIS BIVARIANTE #
#######################
# Paradas contra Tiros a puerta en contra
goalkeepers
<-
laLigaPlayers
[
which
(
laLigaPlayers
$
position.1718
==
"GK"
),]
datos
<-
laLigaPlayers
[
which
(
laLigaPlayers
$
position.1718
==
"GK"
)]
puntos2d
(
"saves"
,
"shots_on_target_against"
,
goalkeepers
,
"1718"
,
"firebrick3"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment