# Load the data
fifa <- read.csv("C:/Users/nicho/Downloads/Fifa_Dataset (2).csv")

# View first few rows
head(fifa)
##       id         name                      full_name birth_date age height_cm
## 1 158023     L. Messi Lionel Andrés Messi Cuccittini 1987-06-24  31    170.18
## 2 190460   C. Eriksen   Christian  Dannemann Eriksen 1992-02-14  27    154.94
## 3 195864     P. Pogba                     Paul Pogba 1993-03-15  25    190.50
## 4 198219   L. Insigne                Lorenzo Insigne 1991-06-04  27    162.56
## 5 201024 K. Koulibaly              Kalidou Koulibaly 1991-06-20  27    187.96
## 6 203376  V. van Dijk                Virgil van Dijk 1991-07-08  27    193.04
##   weight_kgs positions nationality overall_rating potential value_euro
## 1       72.1  CF,RW,ST   Argentina             94        94  110500000
## 2       76.2 CAM,RM,CM     Denmark             88        89   69500000
## 3       83.9    CM,CAM      France             88        91   73000000
## 4       59.0     LW,ST       Italy             88        88   62000000
## 5       88.9        CB     Senegal             88        91   60000000
## 6       92.1        CB Netherlands             88        90   59500000
##   wage_euro preferred_foot international_reputation.1.5. weak_foot.1.5.
## 1    565000           Left                             5              4
## 2    205000          Right                             3              5
## 3    255000          Right                             4              4
## 4    165000          Right                             3              4
## 5    135000          Right                             3              3
## 6    215000          Right                             3              3
##   skill_moves.1.5.      work_rate body_type release_clause_euro
## 1                4    Medium/ Low     Messi           226500000
## 2                4   High/ Medium      Lean           133800000
## 3                5   High/ Medium    Normal           144200000
## 4                4   High/ Medium    Normal           105400000
## 5                2     High/ High    Normal           106500000
## 6                2 Medium/ Medium    Normal           114500000
##           club_team club_rating club_position club_jersey_number club_join_date
## 1      FC Barcelona          86            RW                 10     2004-07-01
## 2 Tottenham Hotspur          83           LCM                 23     2013-08-30
## 3 Manchester United          82           LCM                  6     2016-08-09
## 4            Napoli          82            LS                 24     2010-07-01
## 5            Napoli          82           LCB                 26     2014-07-01
## 6         Liverpool          83           LCB                  4     2018-01-01
##   contract_end_year national_team national_rating national_team_position
## 1              2021     Argentina              82                     RF
## 2              2020       Denmark              78                    CAM
## 3              2021        France              84                    RDM
## 4              2022         Italy              83                     LW
## 5              2021                            NA                       
## 6              2023   Netherlands              81                    LCB
##   national_jersey_number crossing finishing heading_accuracy short_passing
## 1                     10       86        95               70            92
## 2                     10       88        81               52            91
## 3                      6       80        75               75            86
## 4                     10       86        77               56            85
## 5                     NA       30        22               83            68
## 6                      4       53        52               83            79
##   volleys dribbling curve freekick_accuracy long_passing ball_control
## 1      86        97    93                94           89           96
## 2      80        84    86                87           89           91
## 3      85        87    85                82           90           90
## 4      74        90    87                77           78           93
## 5      14        69    28                28           60           63
## 6      45        70    60                70           81           76
##   acceleration sprint_speed agility reactions balance shot_power jumping
## 1           91           86      93        95      95         85      68
## 2           76           73      80        88      81         84      50
## 3           71           79      76        82      66         90      83
## 4           94           86      94        83      93         75      53
## 5           70           75      50        82      40         55      81
## 6           74           77      61        87      49         81      88
##   stamina strength long_shots aggression interceptions positioning vision
## 1      72       66         94         48            22          94     94
## 2      92       58         89         46            56          84     91
## 3      88       87         82         78            64          82     88
## 4      75       44         84         34            26          83     87
## 5      75       94         15         87            88          24     49
## 6      75       92         64         82            88          41     60
##   penalties composure marking standing_tackle sliding_tackle GK_diving
## 1        75        96      33              28             26         6
## 2        67        88      59              57             22         9
## 3        82        87      63              67             67         5
## 4        61        83      51              24             22         8
## 5        33        80      91              88             87         7
## 6        62        87      90              89             84        13
##   GK_handling GK_kicking GK_positioning GK_reflexes
## 1          11         15             14           8
## 2          14          7              7           6
## 3           6          2              4           3
## 4           4         14              9          10
## 5          11          7             13           5
## 6          10         13             11          11
##                                                                                                tags
## 1 #Dribbler,#Distance Shooter,#Crosser,#FK Specialist,#Acrobat,#Clinical Finisher,#Complete Forward
## 2                                         #Playmaker  ,#Crosser,#FK Specialist,#Complete Midfielder
## 3                                             #Dribbler,#Playmaker  ,#Strength,#Complete Midfielder
## 4                                                            #Speedster,#Dribbler,#Crosser,#Acrobat
## 5                                               #Tackling ,#Tactician ,#Strength,#Complete Defender
## 6                                                                             #Tactician ,#Strength
##                                                                                                                                                traits
## 1 Finesse Shot,Long Shot Taker (CPU AI Only),Speed Dribbler (CPU AI Only),Playmaker (CPU AI Only),One Club Player,Team Player,Chip Shot (CPU AI Only)
## 2                               Flair,Long Shot Taker (CPU AI Only),Playmaker (CPU AI Only),Technical Dribbler (CPU AI Only),Takes Finesse Free Kicks
## 3                              Flair,Long Passer (CPU AI Only),Long Shot Taker (CPU AI Only),Playmaker (CPU AI Only),Technical Dribbler (CPU AI Only)
## 4                                                    Finesse Shot,Long Shot Taker (CPU AI Only),Speed Dribbler (CPU AI Only),Takes Finesse Free Kicks
## 5                                                                                                                                        Power Header
## 6                                                                                                                 Injury Free,Leadership,Power Header
##     LS   ST   RS   LW   LF   CF   RF   RW  LAM  CAM  RAM   LM  LCM   CM  RCM
## 1 89+2 89+2 89+2 93+2 93+2 93+2 93+2 93+2 93+2 93+2 93+2 91+2 85+2 85+2 85+2
## 2 79+3 79+3 79+3 85+3 84+3 84+3 84+3 85+3 86+3 86+3 86+3 86+3 85+3 85+3 85+3
## 3 81+3 81+3 81+3 82+3 83+3 83+3 83+3 82+3 84+3 84+3 84+3 83+3 84+3 84+3 84+3
## 4 78+3 78+3 78+3 86+3 85+3 85+3 85+3 86+3 86+3 86+3 86+3 86+3 78+3 78+3 78+3
## 5 53+3 53+3 53+3 53+3 54+3 54+3 54+3 53+3 55+3 55+3 55+3 57+3 61+3 61+3 61+3
## 6 68+3 68+3 68+3 66+3 67+3 67+3 67+3 66+3 68+3 68+3 68+3 68+3 73+3 73+3 73+3
##     RM  LWB  LDM  CDM  RDM  RWB   LB  LCB   CB  RCB   RB
## 1 91+2 64+2 61+2 61+2 61+2 64+2 59+2 48+2 48+2 48+2 59+2
## 2 86+3 71+3 71+3 71+3 71+3 71+3 66+3 57+3 57+3 57+3 66+3
## 3 83+3 76+3 77+3 77+3 77+3 76+3 74+3 72+3 72+3 72+3 74+3
## 4 86+3 63+3 58+3 58+3 58+3 63+3 58+3 44+3 44+3 44+3 58+3
## 5 57+3 73+3 77+3 77+3 77+3 73+3 76+3 85+3 85+3 85+3 76+3
## 6 68+3 78+3 82+3 82+3 82+3 78+3 80+3 86+3 86+3 86+3 80+3
# Check for missing values
colSums(is.na(fifa))
##                            id                          name 
##                             0                             0 
##                     full_name                    birth_date 
##                             0                             0 
##                           age                     height_cm 
##                             0                             0 
##                    weight_kgs                     positions 
##                             0                             0 
##                   nationality                overall_rating 
##                             0                             0 
##                     potential                    value_euro 
##                             0                           255 
##                     wage_euro                preferred_foot 
##                           246                             0 
## international_reputation.1.5.                weak_foot.1.5. 
##                             0                             0 
##              skill_moves.1.5.                     work_rate 
##                             0                             0 
##                     body_type           release_clause_euro 
##                             0                          1837 
##                     club_team                   club_rating 
##                             0                            14 
##                 club_position            club_jersey_number 
##                             0                            14 
##                club_join_date             contract_end_year 
##                             0                             0 
##                 national_team               national_rating 
##                             0                         17097 
##        national_team_position        national_jersey_number 
##                             0                         17097 
##                      crossing                     finishing 
##                             0                             0 
##              heading_accuracy                 short_passing 
##                             0                             0 
##                       volleys                     dribbling 
##                             0                             0 
##                         curve             freekick_accuracy 
##                             0                             0 
##                  long_passing                  ball_control 
##                             0                             0 
##                  acceleration                  sprint_speed 
##                             0                             0 
##                       agility                     reactions 
##                             0                             0 
##                       balance                    shot_power 
##                             0                             0 
##                       jumping                       stamina 
##                             0                             0 
##                      strength                    long_shots 
##                             0                             0 
##                    aggression                 interceptions 
##                             0                             0 
##                   positioning                        vision 
##                             0                             0 
##                     penalties                     composure 
##                             0                             0 
##                       marking               standing_tackle 
##                             0                             0 
##                sliding_tackle                     GK_diving 
##                             0                             0 
##                   GK_handling                    GK_kicking 
##                             0                             0 
##                GK_positioning                   GK_reflexes 
##                             0                             0 
##                          tags                        traits 
##                             0                             0 
##                            LS                            ST 
##                             0                             0 
##                            RS                            LW 
##                             0                             0 
##                            LF                            CF 
##                             0                             0 
##                            RF                            RW 
##                             0                             0 
##                           LAM                           CAM 
##                             0                             0 
##                           RAM                            LM 
##                             0                             0 
##                           LCM                            CM 
##                             0                             0 
##                           RCM                            RM 
##                             0                             0 
##                           LWB                           LDM 
##                             0                             0 
##                           CDM                           RDM 
##                             0                             0 
##                           RWB                            LB 
##                             0                             0 
##                           LCB                            CB 
##                             0                             0 
##                           RCB                            RB 
##                             0                             0
fifa %>%
  select(age, overall_rating, potential, value_euro, wage_euro) %>%
  summary()
##       age        overall_rating    potential       value_euro       
##  Min.   :17.00   Min.   :47.00   Min.   :48.00   Min.   :    10000  
##  1st Qu.:22.00   1st Qu.:62.00   1st Qu.:67.00   1st Qu.:   325000  
##  Median :25.00   Median :66.00   Median :71.00   Median :   700000  
##  Mean   :25.57   Mean   :66.24   Mean   :71.43   Mean   :  2479280  
##  3rd Qu.:29.00   3rd Qu.:71.00   3rd Qu.:75.00   3rd Qu.:  2100000  
##  Max.   :46.00   Max.   :94.00   Max.   :95.00   Max.   :110500000  
##                                                  NA's   :255        
##    wage_euro     
##  Min.   :  1000  
##  1st Qu.:  1000  
##  Median :  3000  
##  Mean   :  9902  
##  3rd Qu.:  9000  
##  Max.   :565000  
##  NA's   :246

Insights: This quick scan reveals the structure of the dataset, showing player attributes such as age, ratings, nationality, club info, wages, and value. We also verify if any variables have significant missing values to address before deeper analysis.

Summary statistics show that most players are in their early to mid-20s. There’s a wide range in player wages and market value, indicating a mix of elite and lower-tier players.

Visualizations and Analysis

Insight: Player ages are clustered between 18 and 30, with the peak around 21–25 years old. Very few players are above 35.

## Warning: Removed 246 rows containing non-finite outside the scale range
## (`stat_boxplot()`).

Insight: Forwards and attacking midfielders tend to command higher wages, while goalkeepers and some defenders show lower wage medians. This aligns with how attacking players are often more marketable and in demand.

Insight: Countries like England, Brazil, and Spain have the largest number of players in the dataset, which reflects their deep football culture and large professional leagues.

Choose appropriate data analysis methods and examine the relationships between or among the variables that interest you.

## Warning: Removed 255 rows containing missing values or values outside the scale range
## (`geom_point()`).

Insight: There’s a strong positive correlation between player value and wage, but some outliers exist — players with high wages but relatively lower market value, or vice versa. This could be due to over/underperformance, club dynamics, or contract timing.

Insight: Countries like Germany, Spain, and France show the highest average player ratings, especially when filtering for nations with a meaningful player sample size (20+). These countries are known for producing technically skilled talent and world-class academies.

Insight: Central positions like CAM (Central Attacking Midfielders), CB (Center Backs), and ST (Strikers) tend to have higher median ratings, indicating their core roles in team performance.

## `geom_smooth()` using formula = 'y ~ x'

Insight: Player ratings tend to increase with age up to a point — peaking around 27–29 — and then plateau or decline, which reflects the typical prime years of a professional footballer.