library(dplyr)
##
## Attaching package: '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)
library(tidyverse)
## ── Attaching packages ────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ tibble 3.0.3 ✓ purrr 0.3.4
## ✓ tidyr 1.1.2 ✓ stringr 1.4.0
## ✓ readr 1.3.1 ✓ forcats 0.5.0
## ── Conflicts ───────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
setwd("~/Dropbox/Imperial/MSc CCM&F/R Programming/Lecture 3 - Visions")
FIFA19 <- read_csv("FIFA19.csv")
## Warning: Missing column names filled in: 'X1' [1]
## Parsed with column specification:
## cols(
## .default = col_character(),
## X1 = col_double(),
## ID = col_double(),
## Age = col_double(),
## Overall = col_double(),
## Potential = col_double(),
## Special = col_double(),
## `International Reputation` = col_double(),
## `Weak Foot` = col_double(),
## `Skill Moves` = col_double(),
## `Jersey Number` = col_double(),
## Crossing = col_double(),
## Finishing = col_double(),
## HeadingAccuracy = col_double(),
## ShortPassing = col_double(),
## Volleys = col_double(),
## Dribbling = col_double(),
## Curve = col_double(),
## FKAccuracy = col_double(),
## LongPassing = col_double(),
## BallControl = col_double()
## # ... with 24 more columns
## )
## See spec(...) for full column specifications.
head(FIFA19)
## # A tibble: 6 x 89
## X1 ID Name Age Photo Nationality Flag Overall Potential Club
## <dbl> <dbl> <chr> <dbl> <chr> <chr> <chr> <dbl> <dbl> <chr>
## 1 0 158023 L. M… 31 http… Argentina http… 94 94 FC B…
## 2 1 20801 Cris… 33 http… Portugal http… 94 94 Juve…
## 3 2 190871 Neym… 26 http… Brazil http… 92 93 Pari…
## 4 3 193080 De G… 27 http… Spain http… 91 93 Manc…
## 5 4 192985 K. D… 27 http… Belgium http… 91 92 Manc…
## 6 5 183277 E. H… 27 http… Belgium http… 91 91 Chel…
## # … with 79 more variables: `Club Logo` <chr>, Value <chr>, Wage <chr>,
## # Special <dbl>, `Preferred Foot` <chr>, `International Reputation` <dbl>,
## # `Weak Foot` <dbl>, `Skill Moves` <dbl>, `Work Rate` <chr>, `Body
## # Type` <chr>, `Real Face` <chr>, Position <chr>, `Jersey Number` <dbl>,
## # Joined <chr>, `Loaned From` <chr>, `Contract Valid Until` <chr>,
## # Height <chr>, Weight <chr>, LS <chr>, ST <chr>, RS <chr>, LW <chr>,
## # LF <chr>, CF <chr>, RF <chr>, RW <chr>, LAM <chr>, CAM <chr>, RAM <chr>,
## # LM <chr>, LCM <chr>, CM <chr>, RCM <chr>, RM <chr>, LWB <chr>, LDM <chr>,
## # CDM <chr>, RDM <chr>, RWB <chr>, LB <chr>, LCB <chr>, CB <chr>, RCB <chr>,
## # RB <chr>, Crossing <dbl>, Finishing <dbl>, HeadingAccuracy <dbl>,
## # ShortPassing <dbl>, Volleys <dbl>, Dribbling <dbl>, Curve <dbl>,
## # FKAccuracy <dbl>, LongPassing <dbl>, BallControl <dbl>, Acceleration <dbl>,
## # SprintSpeed <dbl>, Agility <dbl>, Reactions <dbl>, Balance <dbl>,
## # ShotPower <dbl>, Jumping <dbl>, Stamina <dbl>, Strength <dbl>,
## # LongShots <dbl>, Aggression <dbl>, Interceptions <dbl>, Positioning <dbl>,
## # Vision <dbl>, Penalties <dbl>, Composure <dbl>, Marking <dbl>,
## # StandingTackle <dbl>, SlidingTackle <dbl>, GKDiving <dbl>,
## # GKHandling <dbl>, GKKicking <dbl>, GKPositioning <dbl>, GKReflexes <dbl>,
## # `Release Clause` <chr>
ggplot(FIFA19, aes(Age,Overall)) +
geom_smooth() +
theme_light() +
labs(title="Overall Rating vs Age",
subtitle="FIFA 19 Data",
caption="Source: www.kaggle.com",
x = "Age",
y = "Overall Rating")
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
Above shows the relationship between all football players’ overall FIFA 19 rating and their age. As may be expected we see footballers have a low overall rating at a younger age with this gradually increasing until they reach what can be described as the peak of their careers around the age of 30. In their early 30’s the overall rating of football players appears to gradually reduce yet remains considerably higher than when they started their football career.
This trend is to be expected as players mature and improve throughout their career while physically struggling more at the end of their career when they might strategically play the game better than when they started out.