Fifa 19 merupakan video game yang dikembangkan oleh EA Vancouver, sebagai bagian dari seri video game FIFA. FIFA 19 merupakan seri ke 26 dan dirilis pada 28 September 2018 (Wikipedia).
Pada LBB kali ini, saya mencoba melakukan beberapa analisa menggunakan dataset informasi pemain yang ada game FIFA 19. Dataset diperoleh dari situs kaggle.
## -- Attaching packages ---------------------------------------------------------------- tidyverse 1.2.1 --
## v ggplot2 3.2.0 v purrr 0.3.2
## v tibble 2.1.3 v dplyr 0.8.3
## v tidyr 1.0.0 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.4.0
## -- Conflicts ------------------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
##
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
##
## discard
## The following object is masked from 'package:readr':
##
## col_factor
##
## 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
## 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.
ubah_digit <- function(x) {
if(str_detect(x, "M")){
kali = 1000000
} else if (str_detect(x, "K") ) {
kali = 1000
} else {
kali = 1
}
hasil = as.numeric(str_extract(x, "[[:digit:]]+\\.*[[:digit:]]*"))*kali
return(hasil)
}
#fifa[, c("Value", "Wage")] <- lapply(fifa[, c("Value", "Wage")], ubah_digit)
fifa$ValueP <- sapply(fifa$Value, ubah_digit)
fifa$WageP <- sapply(fifa$Wage, ubah_digit)age_grouping <- function(age){
if(age <= 20){
kel_usia = "Kurang dari 20"
} else if(age > 20 & age <= 25) {
kel_usia = "21 - 25"
} else if(age > 25 & age <= 30) {
kel_usia = "26 - 30"
} else if(age > 30 & age <= 35) {
kel_usia = "31 - 35"
} else{
kel_usia = "diatas 35"
}
return(kel_usia)
}
fifa$Age_group <- sapply(fifa$Age, age_grouping)
fifa$Age_group <- as.factor(fifa$Age_group)
fifa$Age_group <- ordered(fifa$Age_group, levels =c( "Kurang dari 20", "21 - 25", "26 - 30", "31 - 35", "diatas 35"))## [1] 0.07502221
dari hasil korelasi diatas, dapat diambil kesimpulan bahwa usia dengan value pemain memiliki hubungan korelasi positif yang tidak terlalu kuat.
ggplot(fifa, aes(x = Age_group, y = ValueP)) +
geom_boxplot(fill = "#7ad2f6") +
scale_y_log10(labels = dollar_format(prefix = "€")) +
labs(x = NULL,
y = NULL) +
theme_economist()Boxplot diatas menunjukan bahwa Value pemain memiliki kecenderungan naik mengikuti usia sampai dengan usia 30 tahun. kemudian turun di usia 31 - 35, dan kemudian turun lagi setelah melewati usia 35 Tahun.
selanjutnya dilihat hubungan antara Value dengan Overall rating pemain.
ggplot(fifa, aes(x = Overall, y = ValueP, col =Overall )) +
geom_jitter() +
scale_y_continuous(labels = dollar_format(prefix = "€")) +
labs(x = "Overall Rating",
y = NULL) +
guides(col = FALSE) +
theme_economist()scatter plot diatas menunjukan bahwa semakin tinggi overall rating pemain, maka value nya juga cenderung akan tinggi.
fifa$Club <- as.character(fifa$Club)
fifa_10 <- fifa %>%
group_by(Club) %>%
summarise(Overall = mean(Overall)) %>%
arrange(desc(Overall)) %>%
head(n = 5)
fifa2 <- fifa %>%
filter(Club %in% fifa_10$Club)
ggplot(fifa2, aes(x = Club, y = Overall)) +
geom_boxplot(fill = "#7ad2f6") +
theme_economist()Box plot diatas menunjukan 5 Club dengan rata - rata overal rating tertinggi. Dapat dilihat, Juventus menempati peringkat pertama.
Selanjutnya saya ingin melakukan analisa terhadap klub Juventus :
plot_juve <- fifa %>%
filter(Club == "Juventus") %>%
ggplot(aes(x = reorder(Name, ValueP), y = ValueP,
fill = Age_group, text = paste(Name,"<br>",
"Usia : ", Age, "<br>",
"Value : ",Value))) +
geom_col() +
scale_y_continuous(labels = dollar_format(prefix = "€"))+
labs(title = "Grafik Pemain Berdasarkan Value",
subtitle = "dan juga overall ratingnya",
x = "Nama Pemain",
y = NULL) +
coord_flip() +
theme_economist() +
theme(legend.position = "bottom",
legend.title = element_blank()) +
scale_fill_economist()Pada grafik diatas terlihat bahwa Dybala memiliki Value yang lebih tinggi dibandingkan dengan Ronaldo, meskipun Overall rating yang dimiliki Ronaldo lebih tinggi. Hal ini mungkin dikarenakan usia dari Dybala yang lebih muda 9 tahun dari Ronaldo. Dan jika melihat dari grafik perbandingan di bawah, terlihat bahwa Dybala masih memiliki Potential Rating yang cukup tinggi, sementara overall rating Ronaldo sudah mencapai titik potentialnya.
fifa %>%
select("Name", "Age", "Overall", "Potential") %>%
filter(Name %in% c("Cristiano Ronaldo", "P. Dybala"))## # A tibble: 2 x 4
## Name Age Overall Potential
## <chr> <dbl> <dbl> <dbl>
## 1 Cristiano Ronaldo 33 94 94
## 2 P. Dybala 24 89 94
plot_RD <- fifa %>%
filter(Name %in% c("Cristiano Ronaldo", "P. Dybala")) %>%
gather(key ="val", value = "angka", Overall, Potential) %>%
ggplot(aes(x = reorder(Name, ValueP), y = angka,
fill= val, text = paste(Name,"<br>",
"Usia : ", Age, "<br>",
"Value : ",Value, "<br>",
val," : ", angka) )) +
geom_col(position = "dodge") +
labs(x = "Nama Pemain",
y = "Rating") +
coord_flip() +
theme_economist() +
theme(legend.position = "bottom",
legend.title = element_blank()) +
scale_fill_economist()Mencari pemain dengan potential rating tinggi dan Value yang rendah
plot_pot85<- fifa %>%
select(Name, Age,Value, ValueP, Club, Position, Overall, Potential) %>%
filter(Potential >= 85 & ValueP <= mean(ValueP)) %>%
arrange(ValueP) %>%
head(n = 20) %>%
gather(key ="val", value = "angka", Overall, Potential) %>%
ggplot(aes(x = reorder(Name, -ValueP), y = angka,
fill= val, text = paste(Name,"<br>",
"Usia : ", Age, "<br>",
"Club : ", Club, "<br>",
"Value : ",Value, "<br>",
val," : ", angka))) +
geom_col(position = "dodge") +
#geom_text(aes(x = Name ,
# y = 13,
# label= paste(Age, Value, sep = " | " ))) +
coord_flip() +
labs(title = "Graph Pemain Dengan Potential Rating 85 keatas",
subtitle = "dan Value dibawah rata - rata",
x = "Nama Pemain",
y = "Rating") +
theme_economist() +
theme(legend.position = "bottom",
legend.title = element_blank()) +
scale_fill_economist()Plot di atas menunjukan 20 pemain dengan potential rating diatas 85 dengan Value dibawah rata - rata. L. Paredes merupakan pemain dengan overall rating yang tinggi(80), bahkan memiliki potential rating yang lebih tinggi lagi (85) dan Value nya 0 atau masih belum tervaluasi (belum memiliki Club).