the data

library(tidyverse)


#data
q <- read.csv("C:/Users/emretoros/OneDrive/Makale/futbol/instat/tr_uk2.csv", stringsAsFactors=FALSE)

#seperate non-numerics
z <- q %>% 
  select(1:4)

#convert to numeric
w <- q %>%
  select(5:50) %>%
  mutate_if(is.character, as.numeric)

#combine
deneme <- cbind(z,w)

 deneme[is.na(deneme)] <- 0


#clean variable names with janitor
library(janitor)
deneme <- clean_names(deneme)

The PCA

#change name of player col
deneme <- deneme %>%
  rename(Name = i_name)

fa <- deneme %>% 
  select(5:50) 

library(sjPlot)
sjt.fa(fa)
## Parallel analysis suggests that the number of factors =  8  and the number of components =  NA
Factor Analysis
  Factor 1 Factor 2 Factor 3 Factor 4 Factor 5 Factor 6 Factor 7 Factor 8
age -0.16 0.04 0.54 0.11 -0.04 0.03 -0.05 0.05
height -0.04 -0.02 0.55 0.09 -0.09 -0.00 -0.05 0.04
weight -0.08 -0.07 0.60 0.01 0.01 0.05 0.01 -0.03
in_stat_index -0.05 0.12 0.67 0.06 0.00 0.13 0.02 0.01
minutes_played_average_per_match 0.32 0.59 0.16 0.09 0.02 -0.34 -0.05 0.02
goals_average_per_match -0.11 0.05 -0.06 0.41 -0.03 -0.13 0.65 -0.04
shots_average_per_match 0.11 0.10 -0.07 0.70 0.05 0.02 0.16 0.03
passes_average_per_match -0.15 1.03 0.05 0.11 0.00 0.08 -0.06 0.03
accurate_passes -0.02 -0.06 -0.08 0.15 0.01 1.02 -0.09 -0.13
challenges_average_per_match 1.00 0.01 0.01 0.03 -0.01 0.01 -0.05 -0.05
challenges_won 0.04 0.13 -0.07 -0.04 -0.08 0.65 0.01 0.07
dribbles_average_per_match 0.66 -0.12 -0.03 -0.01 0.14 -0.00 -0.06 0.22
successful_dribbles 0.13 0.06 0.15 -0.03 0.00 0.37 0.06 -0.00
tackles_total 0.14 0.19 0.84 -0.41 0.02 -0.04 0.09 -0.03
tackles_won 0.15 0.11 0.07 -0.02 -0.05 0.38 0.05 0.02
starting_lineup_appearances_total 0.14 0.12 0.96 -0.08 -0.02 -0.15 0.05 -0.01
substitute_out_total 0.12 -0.09 0.82 -0.12 0.08 -0.16 0.12 -0.04
assists_average_per_match -0.03 0.00 0.04 -0.01 0.54 -0.02 -0.05 -0.04
chances_average_per_match 0.12 -0.09 -0.11 0.65 -0.01 -0.04 0.29 -0.03
chances_successful_average_per_match -0.02 -0.00 -0.06 0.27 -0.07 -0.07 0.85 0.01
d_hances_created_average_per_match 0.05 -0.03 -0.12 0.28 0.61 -0.04 0.10 0.01
chances_of_conversion -0.10 0.04 0.16 0.01 -0.03 -0.02 0.66 0.04
fouls_suffered_average_per_match 0.54 0.01 -0.01 -0.01 0.12 0.05 0.01 -0.04
total_actions_average_per_match 0.23 0.79 0.04 0.06 0.01 0.07 -0.04 0.03
successful_actions -0.13 0.11 -0.09 0.04 -0.01 1.03 -0.04 -0.00
shots_on_target 0.14 -0.15 0.05 0.21 0.03 0.14 0.23 0.02
shots_wide_average_per_match 0.04 0.14 -0.07 0.59 0.02 0.03 0.00 0.02
fouls_average_per_match 0.58 0.16 0.00 0.05 -0.17 0.08 -0.13 -0.13
accurate_passes_average_per_match -0.23 1.07 0.05 0.11 0.00 0.11 -0.06 -0.03
key_passes_average_per_match -0.04 0.14 -0.04 0.01 0.82 -0.06 -0.01 0.07
key_passes_accurate_average_per_match -0.03 0.03 -0.14 -0.08 1.06 -0.07 -0.05 -0.02
key_passes_accuracy 0.07 -0.14 0.15 -0.06 0.58 0.15 -0.01 -0.11
crosses_average_per_match 0.17 0.01 0.00 -0.08 -0.10 -0.12 0.06 0.98
crosses_accurate_average_per_match 0.01 -0.03 -0.05 -0.09 0.01 -0.03 0.04 0.84
accurate_crosses -0.08 -0.04 0.09 0.01 0.09 0.14 -0.04 0.25
lost_balls_average_per_match 0.79 0.05 0.01 0.24 -0.05 -0.08 -0.06 0.16
lost_balls_in_own_half_average_per_match 0.64 0.15 -0.14 -0.03 -0.09 0.03 -0.00 0.07
ball_recoveries_average_per_match 0.15 0.59 -0.07 -0.31 0.00 0.12 0.15 -0.00
ball_recoveries_in_opponent_s_half_average_per_match 0.10 0.48 -0.19 -0.18 0.19 0.09 0.18 -0.13
x_g_expected_goals_average_per_match 0.05 0.02 0.01 0.91 -0.00 -0.00 -0.00 -0.07
expected_assists_average_per_match -0.06 0.19 0.00 0.16 0.60 -0.07 -0.05 0.13
x_g_per_shot_average_per_match 0.05 -0.08 0.19 0.61 -0.03 0.12 -0.08 -0.09
x_g_per_goal_average_per_match 0.03 -0.09 0.47 0.35 0.06 -0.08 0.00 -0.08
x_g_conversion_average_per_match -0.09 0.00 0.00 -0.07 -0.04 0.04 0.62 0.02
x_g_with_a_player_on_average_per_match 0.02 0.54 0.07 0.35 0.10 0.11 -0.03 0.02
attacking_challenges_average_per_match 0.96 -0.30 0.04 0.27 0.00 -0.05 -0.08 -0.01
Cronbach’s α 0.83 0.81 0.61 0.75 0.79 0.83 0.42 0.60
library(psych)
library(GPArotation)
fact_data <- deneme %>%
select(5:50) 

fan <- fa(fact_data, nfactors = 8, rotate = "varimax")
print(fan)
## Factor Analysis using method =  minres
## Call: fa(r = fact_data, nfactors = 8, rotate = "varimax")
## Standardized loadings (pattern matrix) based upon correlation matrix
##                                                        MR8   MR1   MR3   MR2
## age                                                  -0.04 -0.05  0.61  0.07
## height                                               -0.06  0.01  0.62  0.06
## weight                                               -0.06 -0.06  0.68  0.06
## in_stat_index                                         0.12  0.11  0.71  0.01
## minutes_played_average_per_match                      0.56  0.45  0.14  0.10
## goals_average_per_match                               0.02  0.02  0.01  0.56
## shots_average_per_match                               0.09  0.26  0.12  0.81
## passes_average_per_match                              0.85  0.22  0.11 -0.02
## accurate_passes                                       0.14  0.12  0.15  0.06
## challenges_average_per_match                          0.29  0.86  0.10  0.22
## challenges_won                                        0.31  0.12  0.06  0.00
## dribbles_average_per_match                            0.13  0.59  0.07  0.15
## successful_dribbles                                   0.21  0.19  0.22  0.03
## tackles_total                                         0.36  0.13  0.66 -0.14
## tackles_won                                           0.24  0.21  0.17  0.03
## starting_lineup_appearances_total                     0.21  0.20  0.85  0.08
## substitute_out_total                                  0.02  0.13  0.68  0.10
## assists_average_per_match                             0.05  0.07  0.11  0.04
## chances_average_per_match                            -0.09  0.21  0.03  0.73
## chances_successful_average_per_match                  0.07  0.07 -0.01  0.54
## d_hances_created_average_per_match                    0.07  0.18  0.04  0.47
## chances_of_conversion                                 0.07  0.03  0.16  0.12
## fouls_suffered_average_per_match                      0.21  0.52  0.05  0.14
## total_actions_average_per_match                       0.79  0.47  0.11  0.06
## successful_actions                                    0.30  0.06  0.12 -0.03
## shots_on_target                                      -0.11  0.23  0.16  0.15
## shots_wide_average_per_match                          0.12  0.15  0.08  0.67
## fouls_average_per_match                               0.26  0.54  0.06  0.03
## accurate_passes_average_per_match                     0.86  0.16  0.10 -0.04
## key_passes_average_per_match                          0.24  0.16  0.13  0.20
## key_passes_accurate_average_per_match                 0.17  0.12  0.03  0.16
## key_passes_accuracy                                   0.04  0.09  0.26  0.11
## crosses_average_per_match                             0.13  0.22  0.10  0.00
## crosses_accurate_average_per_match                    0.05  0.05  0.04  0.00
## accurate_crosses                                     -0.03 -0.03  0.16  0.01
## lost_balls_average_per_match                          0.18  0.82  0.13  0.28
## lost_balls_in_own_half_average_per_match              0.29  0.62 -0.09  0.02
## ball_recoveries_average_per_match                     0.79  0.17 -0.09 -0.10
## ball_recoveries_in_opponent_s_half_average_per_match  0.65  0.14 -0.18  0.04
## x_g_expected_goals_average_per_match                 -0.10  0.23  0.20  0.79
## expected_assists_average_per_match                    0.19  0.17  0.14  0.19
## x_g_per_shot_average_per_match                       -0.18  0.19  0.34  0.38
## x_g_per_goal_average_per_match                       -0.11  0.11  0.49  0.33
## x_g_conversion_average_per_match                      0.04  0.01  0.01  0.03
## x_g_with_a_player_on_average_per_match                0.51  0.29  0.21  0.25
## attacking_challenges_average_per_match               -0.09  0.85  0.17  0.38
##                                                        MR4   MR6   MR5   MR7
## age                                                   0.04  0.11 -0.01  0.10
## height                                                0.00  0.08 -0.01  0.07
## weight                                                0.05  0.11  0.02  0.04
## in_stat_index                                         0.23  0.27  0.16  0.03
## minutes_played_average_per_match                      0.18 -0.14  0.03  0.02
## goals_average_per_match                               0.07 -0.12  0.57 -0.01
## shots_average_per_match                               0.21  0.07  0.16  0.07
## passes_average_per_match                              0.17  0.29  0.00  0.11
## accurate_passes                                       0.12  0.80  0.04  0.02
## challenges_average_per_match                          0.13  0.17  0.05  0.01
## challenges_won                                        0.00  0.66  0.01  0.10
## dribbles_average_per_match                            0.27  0.09  0.03  0.20
## successful_dribbles                                   0.13  0.44  0.08  0.02
## tackles_total                                         0.06  0.16  0.01  0.07
## tackles_won                                           0.05  0.49  0.08  0.06
## starting_lineup_appearances_total                     0.12  0.02  0.05  0.06
## substitute_out_total                                  0.13 -0.04  0.07  0.04
## assists_average_per_match                             0.51  0.03  0.03  0.05
## chances_average_per_match                             0.16 -0.03  0.29 -0.04
## chances_successful_average_per_match                  0.04 -0.03  0.70  0.04
## d_hances_created_average_per_match                    0.62  0.03  0.13  0.14
## chances_of_conversion                                 0.09  0.06  0.76  0.03
## fouls_suffered_average_per_match                      0.16  0.13  0.05  0.04
## total_actions_average_per_match                       0.18  0.28  0.02  0.11
## successful_actions                                    0.10  0.91  0.03  0.11
## shots_on_target                                       0.20  0.18  0.44 -0.01
## shots_wide_average_per_match                          0.12  0.06 -0.05  0.07
## fouls_average_per_match                              -0.06  0.17 -0.03 -0.09
## accurate_passes_average_per_match                     0.16  0.31  0.00  0.06
## key_passes_average_per_match                          0.68  0.07  0.05  0.20
## key_passes_accurate_average_per_match                 0.85  0.05  0.03  0.16
## key_passes_accuracy                                   0.51  0.23  0.08  0.03
## crosses_average_per_match                             0.21  0.02  0.06  0.69
## crosses_accurate_average_per_match                    0.17  0.04  0.01  0.99
## accurate_crosses                                      0.16  0.16  0.00  0.43
## lost_balls_average_per_match                          0.19  0.06  0.09  0.13
## lost_balls_in_own_half_average_per_match              0.04  0.13  0.06  0.08
## ball_recoveries_average_per_match                     0.01  0.27  0.01  0.04
## ball_recoveries_in_opponent_s_half_average_per_match  0.14  0.20  0.05 -0.05
## x_g_expected_goals_average_per_match                  0.24  0.01  0.15 -0.09
## expected_assists_average_per_match                    0.66  0.06  0.07  0.22
## x_g_per_shot_average_per_match                        0.21  0.14  0.20 -0.13
## x_g_per_goal_average_per_match                        0.20  0.00  0.14 -0.06
## x_g_conversion_average_per_match                      0.00  0.06  0.70  0.03
## x_g_with_a_player_on_average_per_match                0.34  0.26  0.10  0.04
## attacking_challenges_average_per_match                0.20  0.05  0.09  0.01
##                                                        h2     u2 com
## age                                                  0.41  0.591 1.2
## height                                               0.41  0.594 1.1
## weight                                               0.49  0.512 1.1
## in_stat_index                                        0.68  0.323 1.8
## minutes_played_average_per_match                     0.60  0.402 2.6
## goals_average_per_match                              0.66  0.342 2.1
## shots_average_per_match                              0.84  0.164 1.6
## passes_average_per_match                             0.92  0.083 1.5
## accurate_passes                                      0.72  0.282 1.3
## challenges_average_per_match                         0.94  0.062 1.5
## challenges_won                                       0.55  0.447 1.6
## dribbles_average_per_match                           0.52  0.480 2.0
## successful_dribbles                                  0.35  0.653 2.8
## tackles_total                                        0.64  0.364 2.0
## tackles_won                                          0.38  0.620 2.3
## starting_lineup_appearances_total                    0.84  0.162 1.3
## substitute_out_total                                 0.51  0.490 1.2
## assists_average_per_match                            0.29  0.713 1.2
## chances_average_per_match                            0.69  0.307 1.7
## chances_successful_average_per_match                 0.80  0.198 2.0
## d_hances_created_average_per_match                   0.68  0.318 2.3
## chances_of_conversion                                0.63  0.368 1.2
## fouls_suffered_average_per_match                     0.39  0.615 1.9
## total_actions_average_per_match                      0.98  0.018 2.2
## successful_actions                                   0.95  0.048 1.3
## shots_on_target                                      0.38  0.623 3.3
## shots_wide_average_per_match                         0.52  0.481 1.3
## fouls_average_per_match                              0.40  0.603 1.8
## accurate_passes_average_per_match                    0.90  0.105 1.5
## key_passes_average_per_match                         0.66  0.344 1.9
## key_passes_accurate_average_per_match                0.82  0.180 1.3
## key_passes_accuracy                                  0.41  0.589 2.2
## crosses_average_per_match                            0.60  0.398 1.5
## crosses_accurate_average_per_match                   1.02 -0.018 1.1
## accurate_crosses                                     0.27  0.734 1.9
## lost_balls_average_per_match                         0.86  0.141 1.6
## lost_balls_in_own_half_average_per_match             0.51  0.493 1.6
## ball_recoveries_average_per_match                    0.74  0.259 1.4
## ball_recoveries_in_opponent_s_half_average_per_match 0.54  0.456 1.6
## x_g_expected_goals_average_per_match                 0.82  0.179 1.7
## expected_assists_average_per_match                   0.62  0.383 1.9
## x_g_per_shot_average_per_match                       0.44  0.555 5.0
## x_g_per_goal_average_per_match                       0.43  0.565 2.6
## x_g_conversion_average_per_match                     0.49  0.506 1.0
## x_g_with_a_player_on_average_per_match               0.64  0.358 4.3
## attacking_challenges_average_per_match               0.94  0.060 1.7
## 
##                        MR8  MR1  MR3  MR2  MR4  MR6  MR5  MR7
## SS loadings           4.80 4.72 4.29 3.97 3.50 3.20 2.39 1.99
## Proportion Var        0.10 0.10 0.09 0.09 0.08 0.07 0.05 0.04
## Cumulative Var        0.10 0.21 0.30 0.39 0.46 0.53 0.58 0.63
## Proportion Explained  0.17 0.16 0.15 0.14 0.12 0.11 0.08 0.07
## Cumulative Proportion 0.17 0.33 0.48 0.62 0.74 0.85 0.93 1.00
## 
## Mean item complexity =  1.8
## Test of the hypothesis that 8 factors are sufficient.
## 
## The degrees of freedom for the null model are  1035  and the objective function was  48 with Chi Square of  26105.51
## The degrees of freedom for the model are 695  and the objective function was  12.5 
## 
## The root mean square of the residuals (RMSR) is  0.03 
## The df corrected root mean square of the residuals is  0.04 
## 
## The harmonic number of observations is  561 with the empirical chi square  1115.31  with prob <  4.5e-22 
## The total number of observations was  561  with Likelihood Chi Square =  6729.24  with prob <  0 
## 
## Tucker Lewis Index of factoring reliability =  0.638
## RMSEA index =  0.124  and the 90 % confidence intervals are  0.122 0.127
## BIC =  2330.08
## Fit based upon off diagonal values = 0.99
print(fan$loadings, cutoff = 0.5)
## 
## Loadings:
##                                                      MR8    MR1    MR3   
## age                                                                 0.614
## height                                                              0.621
## weight                                                              0.680
## in_stat_index                                                       0.706
## minutes_played_average_per_match                      0.557              
## goals_average_per_match                                                  
## shots_average_per_match                                                  
## passes_average_per_match                              0.854              
## accurate_passes                                                          
## challenges_average_per_match                                 0.864       
## challenges_won                                                           
## dribbles_average_per_match                                   0.594       
## successful_dribbles                                                      
## tackles_total                                                       0.658
## tackles_won                                                              
## starting_lineup_appearances_total                                   0.851
## substitute_out_total                                                0.676
## assists_average_per_match                                                
## chances_average_per_match                                                
## chances_successful_average_per_match                                     
## d_hances_created_average_per_match                                       
## chances_of_conversion                                                    
## fouls_suffered_average_per_match                             0.522       
## total_actions_average_per_match                       0.789              
## successful_actions                                                       
## shots_on_target                                                          
## shots_wide_average_per_match                                             
## fouls_average_per_match                                      0.536       
## accurate_passes_average_per_match                     0.856              
## key_passes_average_per_match                                             
## key_passes_accurate_average_per_match                                    
## key_passes_accuracy                                                      
## crosses_average_per_match                                                
## crosses_accurate_average_per_match                                       
## accurate_crosses                                                         
## lost_balls_average_per_match                                 0.815       
## lost_balls_in_own_half_average_per_match                     0.622       
## ball_recoveries_average_per_match                     0.787              
## ball_recoveries_in_opponent_s_half_average_per_match  0.652              
## x_g_expected_goals_average_per_match                                     
## expected_assists_average_per_match                                       
## x_g_per_shot_average_per_match                                           
## x_g_per_goal_average_per_match                                           
## x_g_conversion_average_per_match                                         
## x_g_with_a_player_on_average_per_match                0.506              
## attacking_challenges_average_per_match                       0.845       
##                                                      MR2    MR4    MR6   
## age                                                                      
## height                                                                   
## weight                                                                   
## in_stat_index                                                            
## minutes_played_average_per_match                                         
## goals_average_per_match                               0.559              
## shots_average_per_match                               0.815              
## passes_average_per_match                                                 
## accurate_passes                                                     0.800
## challenges_average_per_match                                             
## challenges_won                                                      0.656
## dribbles_average_per_match                                               
## successful_dribbles                                                      
## tackles_total                                                            
## tackles_won                                                              
## starting_lineup_appearances_total                                        
## substitute_out_total                                                     
## assists_average_per_match                                    0.510       
## chances_average_per_match                             0.726              
## chances_successful_average_per_match                  0.545              
## d_hances_created_average_per_match                           0.621       
## chances_of_conversion                                                    
## fouls_suffered_average_per_match                                         
## total_actions_average_per_match                                          
## successful_actions                                                  0.906
## shots_on_target                                                          
## shots_wide_average_per_match                          0.671              
## fouls_average_per_match                                                  
## accurate_passes_average_per_match                                        
## key_passes_average_per_match                                 0.683       
## key_passes_accurate_average_per_match                        0.850       
## key_passes_accuracy                                          0.512       
## crosses_average_per_match                                                
## crosses_accurate_average_per_match                                       
## accurate_crosses                                                         
## lost_balls_average_per_match                                             
## lost_balls_in_own_half_average_per_match                                 
## ball_recoveries_average_per_match                                        
## ball_recoveries_in_opponent_s_half_average_per_match                     
## x_g_expected_goals_average_per_match                  0.794              
## expected_assists_average_per_match                           0.664       
## x_g_per_shot_average_per_match                                           
## x_g_per_goal_average_per_match                                           
## x_g_conversion_average_per_match                                         
## x_g_with_a_player_on_average_per_match                                   
## attacking_challenges_average_per_match                                   
##                                                      MR5    MR7   
## age                                                               
## height                                                            
## weight                                                            
## in_stat_index                                                     
## minutes_played_average_per_match                                  
## goals_average_per_match                               0.570       
## shots_average_per_match                                           
## passes_average_per_match                                          
## accurate_passes                                                   
## challenges_average_per_match                                      
## challenges_won                                                    
## dribbles_average_per_match                                        
## successful_dribbles                                               
## tackles_total                                                     
## tackles_won                                                       
## starting_lineup_appearances_total                                 
## substitute_out_total                                              
## assists_average_per_match                                         
## chances_average_per_match                                         
## chances_successful_average_per_match                  0.701       
## d_hances_created_average_per_match                                
## chances_of_conversion                                 0.756       
## fouls_suffered_average_per_match                                  
## total_actions_average_per_match                                   
## successful_actions                                                
## shots_on_target                                                   
## shots_wide_average_per_match                                      
## fouls_average_per_match                                           
## accurate_passes_average_per_match                                 
## key_passes_average_per_match                                      
## key_passes_accurate_average_per_match                             
## key_passes_accuracy                                               
## crosses_average_per_match                                    0.693
## crosses_accurate_average_per_match                           0.990
## accurate_crosses                                                  
## lost_balls_average_per_match                                      
## lost_balls_in_own_half_average_per_match                          
## ball_recoveries_average_per_match                                 
## ball_recoveries_in_opponent_s_half_average_per_match              
## x_g_expected_goals_average_per_match                              
## expected_assists_average_per_match                                
## x_g_per_shot_average_per_match                                    
## x_g_per_goal_average_per_match                                    
## x_g_conversion_average_per_match                      0.698       
## x_g_with_a_player_on_average_per_match                            
## attacking_challenges_average_per_match                            
## 
##                  MR8   MR1   MR3   MR2   MR4   MR6   MR5   MR7
## SS loadings    4.796 4.720 4.294 3.968 3.505 3.196 2.387 1.985
## Proportion Var 0.104 0.103 0.093 0.086 0.076 0.069 0.052 0.043
## Cumulative Var 0.104 0.207 0.300 0.386 0.463 0.532 0.584 0.627
coefs <- as.data.frame(fan$scores)
deneme_new1 <- cbind(deneme, coefs)



#Look at loadings
loadings(fan,sort=TRUE)
## 
## Loadings:
##                                                      MR8    MR1    MR3   
## age                                                                 0.614
## height                                                              0.621
## weight                                                              0.680
## in_stat_index                                         0.122  0.113  0.706
## minutes_played_average_per_match                      0.557  0.452  0.139
## goals_average_per_match                                                  
## shots_average_per_match                                      0.263  0.116
## passes_average_per_match                              0.854  0.224  0.106
## accurate_passes                                       0.144  0.119  0.150
## challenges_average_per_match                          0.292  0.864       
## challenges_won                                        0.306  0.122       
## dribbles_average_per_match                            0.126  0.594       
## successful_dribbles                                   0.208  0.187  0.225
## tackles_total                                         0.363  0.131  0.658
## tackles_won                                           0.243  0.207  0.166
## starting_lineup_appearances_total                     0.207  0.203  0.851
## substitute_out_total                                         0.129  0.676
## assists_average_per_match                                           0.113
## chances_average_per_match                                    0.212       
## chances_successful_average_per_match                                     
## d_hances_created_average_per_match                           0.176       
## chances_of_conversion                                               0.161
## fouls_suffered_average_per_match                      0.209  0.522       
## total_actions_average_per_match                       0.789  0.466  0.112
## successful_actions                                    0.298         0.123
## shots_on_target                                      -0.112  0.226  0.161
## shots_wide_average_per_match                          0.122  0.146       
## fouls_average_per_match                               0.257  0.536       
## accurate_passes_average_per_match                     0.856  0.164  0.102
## key_passes_average_per_match                          0.239  0.163  0.126
## key_passes_accurate_average_per_match                 0.170  0.121       
## key_passes_accuracy                                                 0.262
## crosses_average_per_match                             0.132  0.220       
## crosses_accurate_average_per_match                                       
## accurate_crosses                                                    0.161
## lost_balls_average_per_match                          0.180  0.815  0.134
## lost_balls_in_own_half_average_per_match              0.291  0.622       
## ball_recoveries_average_per_match                     0.787  0.165       
## ball_recoveries_in_opponent_s_half_average_per_match  0.652  0.143 -0.178
## x_g_expected_goals_average_per_match                 -0.100  0.231  0.201
## expected_assists_average_per_match                    0.188  0.174  0.136
## x_g_per_shot_average_per_match                       -0.176  0.189  0.339
## x_g_per_goal_average_per_match                       -0.108  0.105  0.492
## x_g_conversion_average_per_match                                         
## x_g_with_a_player_on_average_per_match                0.506  0.291  0.208
## attacking_challenges_average_per_match                       0.845  0.166
##                                                      MR2    MR4    MR6   
## age                                                                 0.107
## height                                                                   
## weight                                                              0.109
## in_stat_index                                                0.229  0.269
## minutes_played_average_per_match                             0.183 -0.143
## goals_average_per_match                               0.559        -0.116
## shots_average_per_match                               0.815  0.214       
## passes_average_per_match                                     0.169  0.292
## accurate_passes                                              0.118  0.800
## challenges_average_per_match                          0.216  0.133  0.175
## challenges_won                                                      0.656
## dribbles_average_per_match                            0.149  0.270       
## successful_dribbles                                          0.127  0.440
## tackles_total                                        -0.142         0.156
## tackles_won                                                         0.488
## starting_lineup_appearances_total                            0.122       
## substitute_out_total                                  0.101  0.131       
## assists_average_per_match                                    0.510       
## chances_average_per_match                             0.726  0.160       
## chances_successful_average_per_match                  0.545              
## d_hances_created_average_per_match                    0.473  0.621       
## chances_of_conversion                                 0.121              
## fouls_suffered_average_per_match                      0.139  0.163  0.130
## total_actions_average_per_match                              0.182  0.284
## successful_actions                                           0.103  0.906
## shots_on_target                                       0.154  0.199  0.182
## shots_wide_average_per_match                          0.671  0.121       
## fouls_average_per_match                                             0.165
## accurate_passes_average_per_match                            0.156  0.308
## key_passes_average_per_match                          0.204  0.683       
## key_passes_accurate_average_per_match                 0.161  0.850       
## key_passes_accuracy                                   0.110  0.512  0.226
## crosses_average_per_match                                    0.205       
## crosses_accurate_average_per_match                           0.172       
## accurate_crosses                                             0.156  0.158
## lost_balls_average_per_match                          0.281  0.187       
## lost_balls_in_own_half_average_per_match                            0.128
## ball_recoveries_average_per_match                    -0.101         0.271
## ball_recoveries_in_opponent_s_half_average_per_match         0.137  0.202
## x_g_expected_goals_average_per_match                  0.794  0.240       
## expected_assists_average_per_match                    0.193  0.664       
## x_g_per_shot_average_per_match                        0.376  0.213  0.138
## x_g_per_goal_average_per_match                        0.328  0.202       
## x_g_conversion_average_per_match                                         
## x_g_with_a_player_on_average_per_match                0.254  0.341  0.257
## attacking_challenges_average_per_match                0.376  0.196       
##                                                      MR5    MR7   
## age                                                               
## height                                                            
## weight                                                            
## in_stat_index                                         0.158       
## minutes_played_average_per_match                                  
## goals_average_per_match                               0.570       
## shots_average_per_match                               0.162       
## passes_average_per_match                                     0.106
## accurate_passes                                                   
## challenges_average_per_match                                      
## challenges_won                                               0.102
## dribbles_average_per_match                                   0.204
## successful_dribbles                                               
## tackles_total                                                     
## tackles_won                                                       
## starting_lineup_appearances_total                                 
## substitute_out_total                                              
## assists_average_per_match                                         
## chances_average_per_match                             0.290       
## chances_successful_average_per_match                  0.701       
## d_hances_created_average_per_match                    0.126  0.137
## chances_of_conversion                                 0.756       
## fouls_suffered_average_per_match                                  
## total_actions_average_per_match                              0.105
## successful_actions                                           0.108
## shots_on_target                                       0.437       
## shots_wide_average_per_match                                      
## fouls_average_per_match                                           
## accurate_passes_average_per_match                                 
## key_passes_average_per_match                                 0.199
## key_passes_accurate_average_per_match                        0.157
## key_passes_accuracy                                               
## crosses_average_per_match                                    0.693
## crosses_accurate_average_per_match                           0.990
## accurate_crosses                                             0.434
## lost_balls_average_per_match                                 0.133
## lost_balls_in_own_half_average_per_match                          
## ball_recoveries_average_per_match                                 
## ball_recoveries_in_opponent_s_half_average_per_match              
## x_g_expected_goals_average_per_match                  0.146       
## expected_assists_average_per_match                           0.217
## x_g_per_shot_average_per_match                        0.203 -0.127
## x_g_per_goal_average_per_match                        0.137       
## x_g_conversion_average_per_match                      0.698       
## x_g_with_a_player_on_average_per_match                            
## attacking_challenges_average_per_match                            
## 
##                  MR8   MR1   MR3   MR2   MR4   MR6   MR5   MR7
## SS loadings    4.796 4.720 4.294 3.968 3.505 3.196 2.387 1.985
## Proportion Var 0.104 0.103 0.093 0.086 0.076 0.069 0.052 0.043
## Cumulative Var 0.104 0.207 0.300 0.386 0.463 0.532 0.584 0.627
#Look at uniqueness
fan$uniquenesses
##                                                  age 
##                                           0.59083627 
##                                               height 
##                                           0.59442886 
##                                               weight 
##                                           0.51183776 
##                                        in_stat_index 
##                                           0.32338580 
##                     minutes_played_average_per_match 
##                                           0.40221359 
##                              goals_average_per_match 
##                                           0.34231534 
##                              shots_average_per_match 
##                                           0.16399812 
##                             passes_average_per_match 
##                                           0.08334695 
##                                      accurate_passes 
##                                           0.28223426 
##                         challenges_average_per_match 
##                                           0.06154526 
##                                       challenges_won 
##                                           0.44697052 
##                           dribbles_average_per_match 
##                                           0.48006611 
##                                  successful_dribbles 
##                                           0.65281726 
##                                        tackles_total 
##                                           0.36411519 
##                                          tackles_won 
##                                           0.62041419 
##                    starting_lineup_appearances_total 
##                                           0.16240235 
##                                 substitute_out_total 
##                                           0.49027677 
##                            assists_average_per_match 
##                                           0.71303735 
##                            chances_average_per_match 
##                                           0.30666940 
##                 chances_successful_average_per_match 
##                                           0.19761614 
##                   d_hances_created_average_per_match 
##                                           0.31842326 
##                                chances_of_conversion 
##                                           0.36799911 
##                     fouls_suffered_average_per_match 
##                                           0.61455452 
##                      total_actions_average_per_match 
##                                           0.01787619 
##                                   successful_actions 
##                                           0.04787734 
##                                      shots_on_target 
##                                           0.62256953 
##                         shots_wide_average_per_match 
##                                           0.48062827 
##                              fouls_average_per_match 
##                                           0.60327640 
##                    accurate_passes_average_per_match 
##                                           0.10451982 
##                         key_passes_average_per_match 
##                                           0.34425228 
##                key_passes_accurate_average_per_match 
##                                           0.17954801 
##                                  key_passes_accuracy 
##                                           0.58872365 
##                            crosses_average_per_match 
##                                           0.39842788 
##                   crosses_accurate_average_per_match 
##                                          -0.01756364 
##                                     accurate_crosses 
##                                           0.73440919 
##                         lost_balls_average_per_match 
##                                           0.14059169 
##             lost_balls_in_own_half_average_per_match 
##                                           0.49290941 
##                    ball_recoveries_average_per_match 
##                                           0.25872752 
## ball_recoveries_in_opponent_s_half_average_per_match 
##                                           0.45623427 
##                 x_g_expected_goals_average_per_match 
##                                           0.17913773 
##                   expected_assists_average_per_match 
##                                           0.38260094 
##                       x_g_per_shot_average_per_match 
##                                           0.55527845 
##                       x_g_per_goal_average_per_match 
##                                           0.56502965 
##                     x_g_conversion_average_per_match 
##                                           0.50556041 
##               x_g_with_a_player_on_average_per_match 
##                                           0.35777547 
##               attacking_challenges_average_per_match 
##                                           0.06015599
deneme_new <- drop_na(deneme_new1)


#Check example of similar players to x
Similarity <- 1-(rowSums(abs(sweep(deneme_new[,51:55],2,unlist(deneme_new[deneme_new["Name"]=="Taylan Antalyali",51:55]))))/
                     max(rowSums(abs(sweep(deneme_new[,51:55],2,unlist(deneme_new[deneme_new["Name"]=="Taylan Antalyali",51:55]))))))

#combine similarity with text features

a <- deneme %>% 
  select(1:8)

SimilarityResult <- cbind.data.frame(a,  Similarity)

#Order results
SimilarityResult<-SimilarityResult[with(SimilarityResult, order(-Similarity)), ]

#Look at most similar players
SimilarityResult[1:10,]
##                 Name                 nationality national_team  foot age height
## 77  Taylan Antalyali                      Turkey             -  left  25    180
## 177    Muhammet Reis                      Turkey             - right  35    180
## 350     Furkan Ozcal             Turkey, Germany             - right  30    170
## 117    Mario Vrancic Bosnia-Herzegovina, Germany             -  left  31    187
## 100          Robinho               Brazil, Spain             - right  36    172
## 2              Pedro                       Spain             -  both  33    167
## 6       Demarai Gray            England, Jamaica       England right  24    180
## 282   Levent Aycicek             Germany, Turkey             - right  26    169
## 312  Cristian Tanase                     Romania             - right  33    177
## 29    Jota Peleteiro                       Spain             -  left  29    180
##     weight in_stat_index Similarity
## 77      75           252  1.0000000
## 177      0           235  0.9548154
## 350     68           208  0.9191789
## 117     78           244  0.9034232
## 100     60           247  0.8979697
## 2       65           298  0.8894274
## 6       74           285  0.8836802
## 282     67           220  0.8836145
## 312     79           216  0.8709405
## 29      70           267  0.8703585