FIFA 21 Data Wrangling

Author

Sammy Odeyemi

Introduction

The FIFA 21 dataset is a comprehensive collection of data related to football players, teams, and matches from the FIFA 21 video game. It includes detailed information such as player attributes, team statistics, and match outcomes. The dataset spans from the game’s release in 2020 . This dataset was obtained from Kaggle.

A preliminary analysis of the FIFA 21 dataset reveals several errors and inconsistencies that need to be addressed. These issues can be corrected using string manipulation techniques along with other data cleaning methods. By cleaning the dataset, we can ensure accurate and reliable data for further analysis and insights.

Libraries Used

The tidyverse library is a collection of R packages that can be used in Data Analysis. Some of the packages to be used are the readr for data import, dplyr for data wrangling, stringr for string manipulation to mention a few. Since these packages are housed and are core packages in the tidyverse. I call this library since it is already installed.

#load libraries 
library(knitr)
library(lubridate) 

Attaching package: 'lubridate'
The following objects are masked from 'package:base':

    date, intersect, setdiff, union
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr   1.1.4     ✔ readr   2.1.5
✔ forcats 1.0.0     ✔ stringr 1.5.1
✔ ggplot2 3.5.1     ✔ tibble  3.2.0
✔ purrr   1.0.1     ✔ tidyr   1.3.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(kableExtra)

Attaching package: 'kableExtra'

The following object is masked from 'package:dplyr':

    group_rows
Note

Should it not be installed, run the code block below before calling the libraries for use.

install.packages(c("tidyverse","lubridate","kableExtra"))

The kableExtra package in R is designed to enhance the functionality of tables

Data Import

The FIFA 21 dataset is a CSV file from Kaggle. To dive deep into the data, I proceeded to import it into RStudio, the IDE for the R Programming Language but not without first setting working directory.

  • Setting Working Directory
setwd("C:/Users/SAMMY/Desktop/FIFA21")
  • Reading in Data
#read in fifa 21 csv
fifa21raw<-read_csv("fifa21 raw data v2.csv")
Rows: 18979 Columns: 77
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (23): Name, LongName, photoUrl, playerUrl, Nationality, Club, Contract, ...
dbl (54): ID, Age, ↓OVA, POT, BOV, Attacking, Crossing, Finishing, Heading A...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

A peek into the dataset just to get familiar with what the data is about :

#examine dataset 
knitr::kable(head(fifa21raw,5))
ID Name LongName photoUrl playerUrl Nationality Age ↓OVA POT Club Contract Positions Height Weight Preferred Foot BOV Best Position Joined Loan Date End Value Wage Release Clause Attacking Crossing Finishing Heading Accuracy Short Passing Volleys Skill Dribbling Curve FK Accuracy Long Passing Ball Control Movement Acceleration Sprint Speed Agility Reactions Balance Power Shot Power Jumping Stamina Strength Long Shots Mentality Aggression Interceptions Positioning Vision Penalties Composure Defending Marking Standing Tackle Sliding Tackle Goalkeeping GK Diving GK Handling GK Kicking GK Positioning GK Reflexes Total Stats Base Stats W/F SM A/W D/W IR PAC SHO PAS DRI DEF PHY Hits
158023 L. Messi Lionel Messi https://cdn.sofifa.com/players/158/023/21_60.png http://sofifa.com/player/158023/lionel-messi/210006/ Argentina 33 93 93 FC Barcelona 2004 ~ 2021 RW, ST, CF 170cm 72kg Left 93 RW Jul 1, 2004 NA €103.5M €560K €138.4M 429 85 95 70 91 88 470 96 93 94 91 96 451 91 80 91 94 95 389 86 68 72 69 94 347 44 40 93 95 75 96 91 32 35 24 54 6 11 15 14 8 2231 466 4 ★ 4★ Medium Low 5 ★ 85 92 91 95 38 65 771
20801 Cristiano Ronaldo C. Ronaldo dos Santos Aveiro https://cdn.sofifa.com/players/020/801/21_60.png http://sofifa.com/player/20801/c-ronaldo-dos-santos-aveiro/210006/ Portugal 35 92 92 Juventus 2018 ~ 2022 ST, LW 187cm 83kg Right 92 ST Jul 10, 2018 NA €63M €220K €75.9M 437 84 95 90 82 86 414 88 81 76 77 92 431 87 91 87 95 71 444 94 95 84 78 93 353 63 29 95 82 84 95 84 28 32 24 58 7 11 15 14 11 2221 464 4 ★ 5★ High Low 5 ★ 89 93 81 89 35 77 562
200389 J. Oblak Jan Oblak https://cdn.sofifa.com/players/200/389/21_60.png http://sofifa.com/player/200389/jan-oblak/210006/ Slovenia 27 91 93 Atlético Madrid 2014 ~ 2023 GK 188cm 87kg Right 91 GK Jul 16, 2014 NA €120M €125K €159.4M 95 13 11 15 43 13 109 12 13 14 40 30 307 43 60 67 88 49 268 59 78 41 78 12 140 34 19 11 65 11 68 57 27 12 18 437 87 92 78 90 90 1413 489 3 ★ 1★ Medium Medium 3 ★ 87 92 78 90 52 90 150
192985 K. De Bruyne Kevin De Bruyne https://cdn.sofifa.com/players/192/985/21_60.png http://sofifa.com/player/192985/kevin-de-bruyne/210006/ Belgium 29 91 91 Manchester City 2015 ~ 2023 CAM, CM 181cm 70kg Right 91 CAM Aug 30, 2015 NA €129M €370K €161M 407 94 82 55 94 82 441 88 85 83 93 92 398 77 76 78 91 76 408 91 63 89 74 91 408 76 66 88 94 84 91 186 68 65 53 56 15 13 5 10 13 2304 485 5 ★ 4★ High High 4 ★ 76 86 93 88 64 78 207
190871 Neymar Jr Neymar da Silva Santos Jr. https://cdn.sofifa.com/players/190/871/21_60.png http://sofifa.com/player/190871/neymar-da-silva-santos-jr/210006/ Brazil 28 91 91 Paris Saint-Germain 2017 ~ 2022 LW, CAM 175cm 68kg Right 91 LW Aug 3, 2017 NA €132M €270K €166.5M 408 85 87 62 87 87 448 95 88 89 81 95 453 94 89 96 91 83 357 80 62 81 50 84 356 51 36 87 90 92 93 94 35 30 29 59 9 9 15 15 11 2175 451 5 ★ 5★ High Medium 5 ★ 91 85 86 94 36 59 595
#Check for Cells with NA
fifa21raw %>% select(ID:Hits) %>% filter(!complete.cases(.)) %>% head(5) %>% knitr::kable()
ID Name LongName photoUrl playerUrl Nationality Age ↓OVA POT Club Contract Positions Height Weight Preferred Foot BOV Best Position Joined Loan Date End Value Wage Release Clause Attacking Crossing Finishing Heading Accuracy Short Passing Volleys Skill Dribbling Curve FK Accuracy Long Passing Ball Control Movement Acceleration Sprint Speed Agility Reactions Balance Power Shot Power Jumping Stamina Strength Long Shots Mentality Aggression Interceptions Positioning Vision Penalties Composure Defending Marking Standing Tackle Sliding Tackle Goalkeeping GK Diving GK Handling GK Kicking GK Positioning GK Reflexes Total Stats Base Stats W/F SM A/W D/W IR PAC SHO PAS DRI DEF PHY Hits
158023 L. Messi Lionel Messi https://cdn.sofifa.com/players/158/023/21_60.png http://sofifa.com/player/158023/lionel-messi/210006/ Argentina 33 93 93 FC Barcelona 2004 ~ 2021 RW, ST, CF 170cm 72kg Left 93 RW Jul 1, 2004 NA €103.5M €560K €138.4M 429 85 95 70 91 88 470 96 93 94 91 96 451 91 80 91 94 95 389 86 68 72 69 94 347 44 40 93 95 75 96 91 32 35 24 54 6 11 15 14 8 2231 466 4 ★ 4★ Medium Low 5 ★ 85 92 91 95 38 65 771
20801 Cristiano Ronaldo C. Ronaldo dos Santos Aveiro https://cdn.sofifa.com/players/020/801/21_60.png http://sofifa.com/player/20801/c-ronaldo-dos-santos-aveiro/210006/ Portugal 35 92 92 Juventus 2018 ~ 2022 ST, LW 187cm 83kg Right 92 ST Jul 10, 2018 NA €63M €220K €75.9M 437 84 95 90 82 86 414 88 81 76 77 92 431 87 91 87 95 71 444 94 95 84 78 93 353 63 29 95 82 84 95 84 28 32 24 58 7 11 15 14 11 2221 464 4 ★ 5★ High Low 5 ★ 89 93 81 89 35 77 562
200389 J. Oblak Jan Oblak https://cdn.sofifa.com/players/200/389/21_60.png http://sofifa.com/player/200389/jan-oblak/210006/ Slovenia 27 91 93 Atlético Madrid 2014 ~ 2023 GK 188cm 87kg Right 91 GK Jul 16, 2014 NA €120M €125K €159.4M 95 13 11 15 43 13 109 12 13 14 40 30 307 43 60 67 88 49 268 59 78 41 78 12 140 34 19 11 65 11 68 57 27 12 18 437 87 92 78 90 90 1413 489 3 ★ 1★ Medium Medium 3 ★ 87 92 78 90 52 90 150
192985 K. De Bruyne Kevin De Bruyne https://cdn.sofifa.com/players/192/985/21_60.png http://sofifa.com/player/192985/kevin-de-bruyne/210006/ Belgium 29 91 91 Manchester City 2015 ~ 2023 CAM, CM 181cm 70kg Right 91 CAM Aug 30, 2015 NA €129M €370K €161M 407 94 82 55 94 82 441 88 85 83 93 92 398 77 76 78 91 76 408 91 63 89 74 91 408 76 66 88 94 84 91 186 68 65 53 56 15 13 5 10 13 2304 485 5 ★ 4★ High High 4 ★ 76 86 93 88 64 78 207
190871 Neymar Jr Neymar da Silva Santos Jr. https://cdn.sofifa.com/players/190/871/21_60.png http://sofifa.com/player/190871/neymar-da-silva-santos-jr/210006/ Brazil 28 91 91 Paris Saint-Germain 2017 ~ 2022 LW, CAM 175cm 68kg Right 91 LW Aug 3, 2017 NA €132M €270K €166.5M 408 85 87 62 87 87 448 95 88 89 81 95 453 94 89 96 91 83 357 80 62 81 50 84 356 51 36 87 90 92 93 94 35 30 29 59 9 9 15 15 11 2175 451 5 ★ 5★ High Medium 5 ★ 91 85 86 94 36 59 595

Data Wrangling

Renaming Columns

Upon examining the dataframe, some column names are inconsistent and badly formatted, hence the need to rename

#renamed ColumnNames for easy readability
fifa21raw<-fifa21raw %>% rename(Overall_Analysis=`↓OVA`,PlayerPotential=POT,
                                Best_Overall=BOV,Joined_National=Joined,
                                Skill_Moves=SM,AttackingWorkRate=`A/W`,
                                DefensiveWorkRate=`D/W`,WeakFootRating=`W/F`,
                                InjuryRating=IR,Shooting=SHO,Pace=PAC,
                                Weight_kg=Weight)

The purpose of this codeblock above is to make the column names in the fifa21raw dataframe more descriptive and easier to understand. This helps improve readability of code, especially when working with the data frame in subsequent analyses or visualizations.

Data Dictionary

Here is the data dictionary describing the columns in the dataframe.

check

To crosscheck the rename() is effected in dataframe

colnames(fifa21raw)
 [1] "ID"                "Name"              "LongName"         
 [4] "photoUrl"          "playerUrl"         "Nationality"      
 [7] "Age"               "Overall_Analysis"  "PlayerPotential"  
[10] "Club"              "Contract"          "Positions"        
[13] "Height"            "Weight_kg"         "Preferred Foot"   
[16] "Best_Overall"      "Best Position"     "Joined_National"  
[19] "Loan Date End"     "Value"             "Wage"             
[22] "Release Clause"    "Attacking"         "Crossing"         
[25] "Finishing"         "Heading Accuracy"  "Short Passing"    
[28] "Volleys"           "Skill"             "Dribbling"        
[31] "Curve"             "FK Accuracy"       "Long Passing"     
[34] "Ball Control"      "Movement"          "Acceleration"     
[37] "Sprint Speed"      "Agility"           "Reactions"        
[40] "Balance"           "Power"             "Shot Power"       
[43] "Jumping"           "Stamina"           "Strength"         
[46] "Long Shots"        "Mentality"         "Aggression"       
[49] "Interceptions"     "Positioning"       "Vision"           
[52] "Penalties"         "Composure"         "Defending"        
[55] "Marking"           "Standing Tackle"   "Sliding Tackle"   
[58] "Goalkeeping"       "GK Diving"         "GK Handling"      
[61] "GK Kicking"        "GK Positioning"    "GK Reflexes"      
[64] "Total Stats"       "Base Stats"        "WeakFootRating"   
[67] "Skill_Moves"       "AttackingWorkRate" "DefensiveWorkRate"
[70] "InjuryRating"      "Pace"              "Shooting"         
[73] "PAS"               "DRI"               "DEF"              
[76] "PHY"               "Hits"             

Club Column

The Club column contains clubs of respective players and upon examining the column, it is populated with nextline characters “\n” which leaves the Club column in bad format.

Here are first 10 observations in the column

fifa21raw %>% select(Club) %>% head(10)
# A tibble: 10 × 1
   Club                         
   <chr>                        
 1 "\n\n\n\nFC Barcelona"       
 2 "\n\n\n\nJuventus"           
 3 "\n\n\n\nAtlético Madrid"    
 4 "\n\n\n\nManchester City"    
 5 "\n\n\n\nParis Saint-Germain"
 6 "\n\n\n\nFC Bayern München"  
 7 "\n\n\n\nLiverpool"          
 8 "\n\n\n\nLiverpool"          
 9 "\n\n\n\nParis Saint-Germain"
10 "\n\n\n\nFC Barcelona"       
#Removed nextline characters found in the club column
fifa21raw<-fifa21raw %>% mutate(Club=str_remove_all(Club,"\n"))

The code chunk above rids the Club column of any nextline characters by use of the str_remove_all()

check

To crosscheck that the column is clear of any nextline characters:

fifa21raw %>% select(Club) %>% head(10)
# A tibble: 10 × 1
   Club               
   <chr>              
 1 FC Barcelona       
 2 Juventus           
 3 Atlético Madrid    
 4 Manchester City    
 5 Paris Saint-Germain
 6 FC Bayern München  
 7 Liverpool          
 8 Liverpool          
 9 Paris Saint-Germain
10 FC Barcelona       

Contract Column

The Contract column contains information about the duration of contracts and loan periods for players.

Here are first 10 observations in the column

fifa21raw %>% select(Contract) 
# A tibble: 18,979 × 1
   Contract   
   <chr>      
 1 2004 ~ 2021
 2 2018 ~ 2022
 3 2014 ~ 2023
 4 2015 ~ 2023
 5 2017 ~ 2022
 6 2014 ~ 2023
 7 2017 ~ 2023
 8 2018 ~ 2024
 9 2018 ~ 2022
10 2014 ~ 2022
# ℹ 18,969 more rows
fifa21raw<-separate(fifa21raw,col = Contract,into = c("start_year","end_year"),sep = "~",remove = F)

fifa21raw<-fifa21raw %>% 
  mutate(Contract_type=case_when(str_detect(start_year,"Free")~"Free", 
                                 str_detect(start_year,"On Loan")~ "Loan",
                                 TRUE~ "Full-Time"),
         start_year=case_when(str_detect(Contract,"Free")~ NA_character_,
                              str_detect(Contract,"On Loan")~NA_character_,
                              TRUE~start_year),
         end_year=case_when(str_detect(Contract,"On Loan")~ str_extract(Contract,"\\d{4}"),
                            TRUE~end_year))

fifa21raw <-fifa21raw %>% mutate(across(c(start_year,end_year),as.numeric))

This code chunk above separates the Contract column into start_year and end_year, classifies contracts as ‘Free’, ‘Loan’, or ‘Full-Time’, handles missing values for start_year and end_year based on contract type, and converts these columns to numeric values for further analysis.

check

To crosscheck that the new columns are created off the existing column to determine what groups are the players’ Contract_type and all changes effected:

knitr::kable(select(fifa21raw,Contract,Contract_type,start_year,end_year) %>% head(10))
Contract Contract_type start_year end_year
2004 ~ 2021 Full-Time 2004 2021
2018 ~ 2022 Full-Time 2018 2022
2014 ~ 2023 Full-Time 2014 2023
2015 ~ 2023 Full-Time 2015 2023
2017 ~ 2022 Full-Time 2017 2022
2014 ~ 2023 Full-Time 2014 2023
2017 ~ 2023 Full-Time 2017 2023
2018 ~ 2024 Full-Time 2018 2024
2018 ~ 2022 Full-Time 2018 2022
2014 ~ 2022 Full-Time 2014 2022

Height

The height column comprises of Players’ Height, some in centimeter and some in feet and inches

such as 199cmand "5'7\"" respectively

knitr::kable(select(fifa21raw,Height) %>% head(10))
Height
170cm
187cm
188cm
181cm
175cm
184cm
175cm
191cm
178cm
187cm

There is the need to then standardize all height measurements and to ensure all values are in the same unit (centimeters)

convert_height_fn<-function(Height) {
  counter<<-1
  for (row in Height) {
    if(str_detect(row,"'"))
             {
               row<-strsplit(row,"'")[[1]]
               feet<-as.numeric(row[[1]])
               inches<-as.numeric(str_remove(row[[2]],"\""))
               cm<-round(((feet*12)+ inches) * 2.54,digits=0)
               Height[counter]<-cm
             }
           else{
             Height[counter]<- as.numeric(str_remove(row,"cm"))
           }
    counter<- counter+1
  }
  return(Height)
  
}

fifa21raw<- mutate(fifa21raw,Height=as.numeric(convert_height_fn(Height))) %>% 
  rename(height_cm=Height)
The convert height function

This function helps to convert and standardize height values ~ some in feet and inches, and others in centimeters for the purpose of consistency and data quality

check

To crosscheck that the height column has been standardized

knitr::kable(select(fifa21raw,height_cm) %>% head(10))
height_cm
170
187
188
181
175
184
175
191
178
187

Weight

The Weight column comprises of Players’ Weight, some in kilogram, some in pounds such as 72kg and 192lbs respectively

knitr::kable(select(fifa21raw,Weight_kg) %>% head(10))
Weight_kg
72kg
83kg
87kg
70kg
68kg
80kg
71kg
91kg
73kg
85kg

There is the need to then standardize all Weight measurements and to ensure all values are in the same unit (centimeters)

convert_weight_fn<- function(Weight_kg){
  counter<<-1
    for (row in Weight_kg) {
      if (str_detect(row,"lbs")) {
        row<-str_remove(row,"lbs")
        row<- round(as.numeric(row)/2.20462,digits=0)
        Weight_kg[counter]<-row
      }
      else{
        row<-str_remove(row,"kg")
      row<- as.numeric(row)
      Weight_kg[counter]<-row
      }
      counter<-counter+1
    }
 return(Weight_kg) 
}

fifa21raw<- mutate(fifa21raw,Weight_kg=as.numeric(convert_weight_fn(Weight_kg)))
The convert weight function

This function helps to convert and standardize weight values ~ some in pounds, kilogram and others in centimeters for the purpose of consistency and data quality

check

To crosscheck that the weight column has been standardized

knitr::kable(select(fifa21raw,Weight_kg) %>% head())
Weight_kg
72
83
87
70
68
80

Joined National Column

The Joined National column is a character column indicating when a player joined up with the National Team but it ideally should be of date datatype.

Here’s what it looks like:

fifa21raw%>%select(`Joined_National`)%>%head(10)%>%knitr::kable()
Joined_National
Jul 1, 2004
Jul 10, 2018
Jul 16, 2014
Aug 30, 2015
Aug 3, 2017
Jul 1, 2014
Jul 1, 2017
Jul 19, 2018
Jul 1, 2018
Jul 1, 2014

It should be in date format and the code chunk beneath ensures of that.

fifa21raw<-fifa21raw %>% mutate(Joined_National=as.Date(Joined_National,format="%b %d, %Y"))

check

To crosscheck that the Joined National column has been standardized to date data type

fifa21raw %>% select(Joined_National) %>% head(10) %>% knitr::kable()
Joined_National
2004-07-01
2018-07-10
2014-07-16
2015-08-30
2017-08-03
2014-07-01
2017-07-01
2018-07-19
2018-07-01
2014-07-01
str(fifa21raw$Joined_National)
 Date[1:18979], format: "2004-07-01" "2018-07-10" "2014-07-16" "2015-08-30" "2017-08-03" ...

Value, Wage and Release Clause Columns

The Value, Wage and Release Clause columns house the worth of a player in the market, their earnings in their clubs and the fee to be paid to release a player from their contract respectively.

 knitr::kable(select(fifa21raw,Value,Wage,`Release Clause`) %>% head(10))
Value Wage Release Clause
€103.5M €560K €138.4M
€63M €220K €75.9M
€120M €125K €159.4M
€129M €370K €161M
€132M €270K €166.5M
€111M €240K €132M
€120.5M €250K €144.3M
€102M €160K €120.3M
€185.5M €160K €203.1M
€110M €260K €147.7M

Upon close examination, the columns are of character datatype and contain the Euro currency symbol (€). Additionally, they use “M” to represent values in millions and “K” to represent values in thousands.

fifa21raw<-fifa21raw %>% mutate(across(c(Value,Wage,`Release Clause`),
 function(col) {
   case_when(
  str_detect(col, "M") ~ as.double(str_replace_all(col, "(€|M)", "")) * 1000000,
  str_detect(col, "K") ~ as.double(str_replace_all(col, "(€|K)", "")) * 1000,
  TRUE ~ as.double(str_replace(col, "€", "")))}))

This code chunk above processes the value, wage, and release clause columns by removing currency symbols and suffixes, removing non-numeric characters and converting to numeric values.

check

To crosscheck that the columns have been appropriately processed (cleaned of currency, millions and thousands symbols and converted to numeric values):

knitr::kable(select(fifa21raw,Value,`Release Clause`,Wage) %>% head(10))
Value Release Clause Wage
103500000 138400000 560000
63000000 75900000 220000
120000000 159400000 125000
129000000 161000000 370000
132000000 166500000 270000
111000000 132000000 240000
120500000 144300000 250000
102000000 120300000 160000
185500000 203100000 160000
110000000 147700000 260000

Weak Foot, Skill Move and Injury Rating Columns

The Weak Foot, Skill Moves, and Injury Rating columns collectively provide insights into a player’s technical skills and physical resilience. The Weak Foot rating (1 to 5 stars) shows proficiency with the non-dominant foot, enhancing versatility. The Skill Moves rating (1 to 5 stars) reflects the ability to perform complex dribbles. The Injury Rating (1 to 5 stars) indicates susceptibility to injuries, with lower ratings suggesting better durability.

A peek at some of the observations in these columns is as below:

fifa21raw %>% select(WeakFootRating,Skill_Moves,InjuryRating) %>% head(5) %>% knitr::kable()
WeakFootRating Skill_Moves InjuryRating
4 ★ 4★ 5 ★
4 ★ 5★ 5 ★
3 ★ 1★ 3 ★
5 ★ 4★ 4 ★
5 ★ 5★ 5 ★

They have similar inconsistency, hence the need to treat them altogether:

fifa21raw <- fifa21raw %>%
  mutate(across(c(WeakFootRating, Skill_Moves, InjuryRating), 
            ~ if_else(str_detect(., "★"), 
                      as.numeric(str_remove(., "★")), 
                      as.numeric(.))
  ))

check

To crosscheck that the columns are clear of the star symbol (★):

fifa21raw %>%select(WeakFootRating,Skill_Moves,InjuryRating) %>% head(5) %>% knitr::kable()
WeakFootRating Skill_Moves InjuryRating
4 4 5
4 5 5
3 1 3
5 4 4
5 5 5

Sub-setting Columns

This is important so as to focus on relevant data and to be rid of unnecessary columns.

fifa21raw <- fifa21raw %>%
  select(ID:Contract, Contract_type, Positions, height_cm, Weight_kg, `Preferred Foot`:Hits)  
fifa21raw %>% select(ID:Hits)%>% head(10) %>% knitr::kable()
ID Name LongName photoUrl playerUrl Nationality Age Overall_Analysis PlayerPotential Club Contract Contract_type Positions height_cm Weight_kg Preferred Foot Best_Overall Best Position Joined_National Loan Date End Value Wage Release Clause Attacking Crossing Finishing Heading Accuracy Short Passing Volleys Skill Dribbling Curve FK Accuracy Long Passing Ball Control Movement Acceleration Sprint Speed Agility Reactions Balance Power Shot Power Jumping Stamina Strength Long Shots Mentality Aggression Interceptions Positioning Vision Penalties Composure Defending Marking Standing Tackle Sliding Tackle Goalkeeping GK Diving GK Handling GK Kicking GK Positioning GK Reflexes Total Stats Base Stats WeakFootRating Skill_Moves AttackingWorkRate DefensiveWorkRate InjuryRating Pace Shooting PAS DRI DEF PHY Hits
158023 L. Messi Lionel Messi https://cdn.sofifa.com/players/158/023/21_60.png http://sofifa.com/player/158023/lionel-messi/210006/ Argentina 33 93 93 FC Barcelona 2004 ~ 2021 Full-Time RW, ST, CF 170 72 Left 93 RW 2004-07-01 NA 103500000 560000 138400000 429 85 95 70 91 88 470 96 93 94 91 96 451 91 80 91 94 95 389 86 68 72 69 94 347 44 40 93 95 75 96 91 32 35 24 54 6 11 15 14 8 2231 466 4 4 Medium Low 5 85 92 91 95 38 65 771
20801 Cristiano Ronaldo C. Ronaldo dos Santos Aveiro https://cdn.sofifa.com/players/020/801/21_60.png http://sofifa.com/player/20801/c-ronaldo-dos-santos-aveiro/210006/ Portugal 35 92 92 Juventus 2018 ~ 2022 Full-Time ST, LW 187 83 Right 92 ST 2018-07-10 NA 63000000 220000 75900000 437 84 95 90 82 86 414 88 81 76 77 92 431 87 91 87 95 71 444 94 95 84 78 93 353 63 29 95 82 84 95 84 28 32 24 58 7 11 15 14 11 2221 464 4 5 High Low 5 89 93 81 89 35 77 562
200389 J. Oblak Jan Oblak https://cdn.sofifa.com/players/200/389/21_60.png http://sofifa.com/player/200389/jan-oblak/210006/ Slovenia 27 91 93 Atlético Madrid 2014 ~ 2023 Full-Time GK 188 87 Right 91 GK 2014-07-16 NA 120000000 125000 159400000 95 13 11 15 43 13 109 12 13 14 40 30 307 43 60 67 88 49 268 59 78 41 78 12 140 34 19 11 65 11 68 57 27 12 18 437 87 92 78 90 90 1413 489 3 1 Medium Medium 3 87 92 78 90 52 90 150
192985 K. De Bruyne Kevin De Bruyne https://cdn.sofifa.com/players/192/985/21_60.png http://sofifa.com/player/192985/kevin-de-bruyne/210006/ Belgium 29 91 91 Manchester City 2015 ~ 2023 Full-Time CAM, CM 181 70 Right 91 CAM 2015-08-30 NA 129000000 370000 161000000 407 94 82 55 94 82 441 88 85 83 93 92 398 77 76 78 91 76 408 91 63 89 74 91 408 76 66 88 94 84 91 186 68 65 53 56 15 13 5 10 13 2304 485 5 4 High High 4 76 86 93 88 64 78 207
190871 Neymar Jr Neymar da Silva Santos Jr. https://cdn.sofifa.com/players/190/871/21_60.png http://sofifa.com/player/190871/neymar-da-silva-santos-jr/210006/ Brazil 28 91 91 Paris Saint-Germain 2017 ~ 2022 Full-Time LW, CAM 175 68 Right 91 LW 2017-08-03 NA 132000000 270000 166500000 408 85 87 62 87 87 448 95 88 89 81 95 453 94 89 96 91 83 357 80 62 81 50 84 356 51 36 87 90 92 93 94 35 30 29 59 9 9 15 15 11 2175 451 5 5 High Medium 5 91 85 86 94 36 59 595
188545 R. Lewandowski Robert Lewandowski https://cdn.sofifa.com/players/188/545/21_60.png http://sofifa.com/player/188545/robert-lewandowski/210006/ Poland 31 91 91 FC Bayern München 2014 ~ 2023 Full-Time ST 184 80 Right 91 ST 2014-07-01 NA 111000000 240000 132000000 423 71 94 85 84 89 407 85 79 85 70 88 407 77 78 77 93 82 420 89 84 76 86 85 391 81 49 94 79 88 88 96 35 42 19 51 15 6 12 8 10 2195 457 4 4 High Medium 4 78 91 78 85 43 82 248
209331 M. Salah Mohamed Salah https://cdn.sofifa.com/players/209/331/21_60.png http://sofifa.com/player/209331/mohamed-salah/210006/ Egypt 28 90 90 Liverpool 2017 ~ 2023 Full-Time RW 175 71 Left 90 RW 2017-07-01 NA 120500000 250000 144300000 392 79 91 59 84 79 406 90 83 69 75 89 460 94 92 91 92 91 393 80 69 85 75 84 376 63 55 91 84 83 90 122 38 43 41 62 14 14 9 11 14 2211 470 3 4 High Medium 3 93 86 81 90 45 75 246
212831 Alisson Alisson Ramses Becker https://cdn.sofifa.com/players/212/831/21_60.png http://sofifa.com/player/212831/alisson-ramses-becker/210006/ Brazil 27 90 91 Liverpool 2018 ~ 2024 Full-Time GK 191 91 Right 90 GK 2018-07-19 NA 102000000 160000 120300000 114 17 13 19 45 20 138 27 19 18 44 30 268 56 47 40 88 37 240 64 52 32 78 14 140 27 11 13 66 23 65 50 15 19 16 439 86 88 85 91 89 1389 490 3 1 Medium Medium 3 86 88 85 89 51 91 120
231747 K. Mbappé Kylian Mbappé https://cdn.sofifa.com/players/231/747/21_60.png http://sofifa.com/player/231747/kylian-mbappe/210006/ France 21 90 95 Paris Saint-Germain 2018 ~ 2022 Full-Time ST, LW, RW 178 73 Right 91 ST 2018-07-01 NA 185500000 160000 203100000 408 78 91 73 83 83 394 92 79 63 70 90 458 96 96 92 92 82 404 86 77 86 76 79 341 62 38 91 80 70 84 100 34 34 32 42 13 5 7 11 6 2147 466 4 5 High Low 3 96 86 78 91 39 76 1.6K
192448 M. ter Stegen Marc-André ter Stegen https://cdn.sofifa.com/players/192/448/21_60.png http://sofifa.com/player/192448/marc-andre-ter-stegen/210006/ Germany 28 90 93 FC Barcelona 2014 ~ 2022 Full-Time GK 187 85 Right 90 GK 2014-07-01 NA 110000000 260000 147700000 118 18 14 11 61 14 144 21 18 12 63 30 254 38 50 37 86 43 268 66 79 35 78 10 171 43 22 11 70 25 70 48 25 13 10 439 88 85 88 88 90 1442 484 4 1 Medium Medium 3 88 85 88 90 45 88 130

Saving Wrangled Data

write_csv(as.data.frame(fifa21raw),"fifa21_cleaned.csv")
Dataset and Source Code

You can access dataset here and source code here

Conclusion

In this project, the FIFA 21 dataset was successfully wrangled by cleaning, transforming, and structuring the data. This process ensured the dataset was accurate, consistent, and ready for analysis. The cleaned data can now be used for various analytical tasks, providing valuable insights into player performance and team comparisons.