-
Notifications
You must be signed in to change notification settings - Fork 0
/
Project-585-WC.R
347 lines (297 loc) · 18 KB
/
Project-585-WC.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
library(XML)
library(plyr)
library(ggplot2)
=============================================================
##### ID's of National Teams and Club Teams on the website
=============================================================
clubs <- read.csv("club teams.csv")
nations <- read.csv("national teams.csv")
=============================================================
##### Getting the data of National Teams frob the web
=============================================================
nat_goalie <- nat_player <- NULL
for(i in nations$id)
{
url <- paste("http://espnfc.com/team/squad/_/id/"
,i,"/season/2013/league/all/brazil?cc=5901",sep="")
table <- readHTMLTable(url)
goalie <- table[[1]]
players <- table[[2]]
nat_goalie <- rbind(nat_goalie,data.frame(goalie, National.Teams = nations$National.Teams[nations$id == i]))
nat_player <- rbind(nat_player,data.frame(players, National.Teams = nations$National.Teams[nations$id == i]))
}
nat_player$GS <- as.numeric(as.character(nat_player$GS))
nat_player$SB <- as.numeric(as.character(nat_player$SB))
nat_player$G <- as.numeric(as.character(nat_player$G))
nat_player$SH <- as.numeric(as.character(nat_player$SH))
nat_player$SG <- as.numeric(as.character(nat_player$SG))
nat_player$A <- as.numeric(as.character(nat_player$A))
nat_player$FC <- as.numeric(as.character(nat_player$FC))
nat_player$FS <- as.numeric(as.character(nat_player$FS))
nat_player$YC <- as.numeric(as.character(nat_player$YC))
nat_player$RC <- as.numeric(as.character(nat_player$RC))
nat_goalie$GS <- as.numeric(as.character(nat_goalie$GS))
nat_goalie$SB <- as.numeric(as.character(nat_goalie$SB))
nat_goalie$SV <- as.numeric(as.character(nat_goalie$SV))
nat_goalie$GC <- as.numeric(as.character(nat_goalie$GC))
nat_goalie$FC <- as.numeric(as.character(nat_goalie$FC))
nat_goalie$FS <- as.numeric(as.character(nat_goalie$FS))
nat_goalie$YC <- as.numeric(as.character(nat_goalie$YC))
nat_goalie$RC <- as.numeric(as.character(nat_goalie$RC))
nat_goalie$W <- as.numeric(as.character(nat_goalie$W))
nat_goalie$L <- as.numeric(as.character(nat_goalie$L))
nat_goalie$D <- as.numeric(as.character(nat_goalie$D))
=============================================================
##### Getting the data for Club Teams frob the web
=============================================================
club_goalie <- club_player <- NULL
for(i in clubs$id)
{
url <- paste("http://espnfc.com/team/squad/_/id/",i,"/season/2013/league/all/manchester-united?cc=5901",sep="")
table <- readHTMLTable(url)
cgoalie <- table[[1]]
cplayers <- table[[2]]
club_goalie <- rbind(club_goalie, data.frame(cgoalie, Teams = clubs$Teams[clubs$id == i], League = clubs$League[clubs$id == i]))
club_player <- rbind(club_player,data.frame(cplayers, Teams = clubs$Teams[clubs$id == i], League = clubs$League[clubs$id == i]))
}
club_player$GS <- as.numeric(as.character(club_player$GS))
club_player$SB <- as.numeric(as.character(club_player$SB))
club_player$G <- as.numeric(as.character(club_player$G))
club_player$SH <- as.numeric(as.character(club_player$SH))
club_player$SG <- as.numeric(as.character(club_player$SG))
club_player$A <- as.numeric(as.character(club_player$A))
club_player$FC <- as.numeric(as.character(club_player$FC))
club_player$FS <- as.numeric(as.character(club_player$FS))
club_player$YC <- as.numeric(as.character(club_player$YC))
club_player$RC <- as.numeric(as.character(club_player$RC))
club_goalie$GS <- as.numeric(as.character(club_goalie$GS))
club_goalie$SB <- as.numeric(as.character(club_goalie$SB))
club_goalie$SV <- as.numeric(as.character(club_goalie$SV))
club_goalie$GC <- as.numeric(as.character(club_goalie$GC))
club_goalie$FC <- as.numeric(as.character(club_goalie$FC))
club_goalie$FS <- as.numeric(as.character(club_goalie$FS))
club_goalie$YC <- as.numeric(as.character(club_goalie$YC))
club_goalie$RC <- as.numeric(as.character(club_goalie$RC))
club_goalie$W <- as.numeric(as.character(club_goalie$W))
club_goalie$L <- as.numeric(as.character(club_goalie$L))
club_goalie$D <- as.numeric(as.character(club_goalie$D))
=============================================================
#### National Teams Impact (Players)
=============================================================
nat_pl <- ddply(nat_player[,-c(1)], .(NAME, National.Teams), summarize, GS=sum(GS),SB=sum(SB),G=sum(G),SH = sum(SH), SG = sum(SG),A = sum(A), FC=sum(FC),FS=sum(FS),YC=sum(YC),RC=sum(RC) )
nat_pl$Played <- nat_pl$GS + nat_pl$SB
nat_pl.sub <- subset(nat_pl, Played > 0)
nat_pl.sub$Cards <- nat_pl.sub$YC + nat_pl.sub$RC
### Clustering
nat_pl.s <- as.data.frame(apply(nat_pl.sub[, -c(1:4, 6, 10:13)], 2, function(x){round(x/nat_pl.sub$Played, 4)}))
#nat_pl.s$Played <- nat_pl.sub$Played
d <- dist(nat_pl.s)
k <- kmeans(d, 3)
nat_pl.sub$cluster <- k$cluster
Players <- data.frame(Name = nat_pl.sub$NAME, Cluster = k$cluster)
nat_pl.new <- subset(nat_pl.sub, select = G:cluster)
nat_pl.new <- as.data.frame(apply(nat_pl.new[, -c(2,6:9, 11)], 2, function(x){x/nat_pl.new$Played}))
nat_pl.new$Played <- nat_pl.sub$Played
nat_pl.new$cluster <- nat_pl.sub$cluster
### plotting the clusters to get an idea about each of the 5 attributes for the 3 clusters
ggpcp(data = nat_pl.new, vars = names(nat_pl.new[c(1:5)])) + geom_line(aes(color = factor(cluster))) + facet_wrap( ~ cluster, nrow = 3 )
mean.nat_pl <- ddply(nat_pl.new, .(cluster), summarize, G = mean(G), SG = mean(SG), A = mean(A), FC = mean(FC), Cards = mean(Cards) )
#ggpcp(data = mean.nat_pl, vars = names(mean.nat_pl[c(2:6)])) + geom_line(aes(color = factor(cluster)))
#mean.nat_pl$Cards <- mean.nat_pl$YC + mean.nat_pl$RC
sum.wt <- as.numeric(apply(mean.nat_pl[, -c(1)], 2, sum))
wt <- ddply(mean.nat_pl, .(cluster), summarize, G.w = G/sum.wt[1], SG.w = SG/sum.wt[2], A.w = A/sum.wt[3], FC.w = FC/sum.wt[4], Cards.w = Cards/sum.wt[5])
#nat_pl.sub$Cards <- nat_pl.sub$YC + nat_pl.sub$RC
nat.players <- nat_pl.sub[, -c(3:4, 6, 10:12)]
nat.pl.1 <- as.data.frame(apply(nat.players[, -c(1:2, 7, 9)], 2, function(x){x/nat.players$Played}))
nat.players <- cbind(nat.players[, c(1:2, 7, 9)], nat.pl.1)
nat.players.m <- merge(nat.players, wt, by = "cluster")
nat.impact <- ddply(nat.players.m, .(cluster, NAME), transform, Impact = G*G.w + SG*SG.w + A*A.w + FC*FC.w + Cards*Cards.w )
nat.team.impact <- ddply(nat.impact, .(National.Teams), summarize, Impact = mean(Impact))
nat.team.impact.ordered <- nat.team.impact[order(nat.team.impact$Impact, decreasing = T), ]
qplot(reorder(National.Teams,Impact),data=nat.team.impact.ordered,weight=Impact,xlab="National Teams",ylab="Impact_Players")+coord_flip()
#clus1 <- subset(nat.impact,cluster==1)
#clus2 <- subset(nat.impact,cluster==2)
#clus3 <- subset(nat.impact,cluster==3)
#clus2[which.max(clus2$Impact),]
#clus2[which.max(clus2$G),]
#clus2[which.max(clus2$A),]
#clus2[which.max(clus2$FC),]
#clus3[which.max(clus3$Impact),]
#clus3[which.max(clus3$G),]
#clus3[which.max(clus3$A),]
#clus3[which.max(clus3$FC),]
#clus1[which.max(clus1$Impact),]
#clus1[which.max(clus1$G),]
#clus1[which.max(clus1$A),]
#clus1[which.max(clus1$FC),]
=============================================================
#### National Teams Impact (Goalkeepers)
=============================================================
nat_gl <- ddply(nat_goalie[,-c(1)], .(NAME, National.Teams), summarize, GS=sum(GS),SB=sum(SB),SV=sum(SV),GC = sum(GC), FC=sum(FC),FS=sum(FS),YC=sum(YC),RC=sum(RC), W = sum(W), L = sum(L), D = sum(D) )
nat_gl$Played <- nat_gl$GS + nat_gl$SB
nat_gl.sub <- subset(nat_gl, Played > 0)
nat_gl.sub$Cards <- nat_gl.sub$YC + nat_gl.sub$RC
#nat_gl.sub$GC <- - nat_gl.sub$GC
Best.goalie.by.nat <- ddply(nat_gl.sub, .(National.Teams), summarize, NAME = NAME[Played == max(Played) ], GS = GS[Played == max(Played) ])
Best.goalie.by.nat <- ddply(nat_gl.sub, .(National.Teams), summarize, NAME = NAME[GS == max(GS)])
Best.goalie.by.nat <- Best.goalie.by.nat[-24, ]
nat_gl.sub <- subset(nat_gl.sub, NAME %in% Best.goalie.by.nat$NAME)
### Clustering
nat_gl.s <- as.data.frame(apply(nat_gl.sub[, -c(1:4, 8:14)], 2, function(x){round(x/nat_gl.sub$Played, 4)}))
#nat_pl.s$Played <- nat_pl.sub$Played
d <- dist(nat_gl.s)
k <- kmeans(d, 2)
nat_gl.sub$cluster <- k$cluster
Players <- data.frame(Name = nat_gl.sub$NAME, Cluster = k$cluster)
nat_gl.new <- subset(nat_gl.sub, select = SV:cluster)
nat_gl.new <- as.data.frame(apply(nat_gl.new[, -c(4:10, 12)], 2, function(x){x/nat_gl.new$Played}))
nat_gl.new$Played <- nat_gl.sub$Played
nat_gl.new$cluster <- nat_gl.sub$cluster
ggpcp(data = nat_gl.new, vars = names(nat_gl.new[c(1:4)])) + geom_line(aes(color = factor(cluster))) + facet_wrap( ~ cluster, nrow = 2 )
#info <- merge(nat_gl.new,nat_gl.sub,by="row.names")[,-c(10:23)]
#clus1 <- subset(info,cluster.x==1)
#clus2 <- subset(info,cluster.x==2)
#clus1[which.max(clus1$SV.x),]
#clus1[which.min(clus1$GC.x),]
#clus1[which.max(clus1$FC.x),]
#clus2[which.max(clus2$FC.x),]
#clus2[which.max(clus2$SV.x),]
#clus2[which.min(clus2$GC.x),]
mean.nat_gl <- ddply(nat_gl.new, .(cluster), summarize, SV = mean(SV), GC = mean(GC), FC = mean(FC), Cards = mean(Cards) )
#ggpcp(data = mean.nat_gl, vars = names(mean.nat_gl[c(2:5)])) + geom_line(aes(color = factor(cluster)))
sum.wt <- as.numeric(apply(mean.nat_gl[, -c(1)], 2, sum))
wt <- ddply(mean.nat_gl, .(cluster), summarize, SV.w = SV/sum.wt[1], GC.w = GC/sum.wt[2], FC.w = FC/sum.wt[3],Cards.w = Cards/sum.wt[4])
#nat_pl.sub$Cards <- nat_pl.sub$YC + nat_pl.sub$RC
nat.goalie <- nat_gl.sub[, -c(3:4, 8:13)]
nat.gl.1 <- as.data.frame(apply(nat.goalie[, -c(1:2, 6, 8)], 2, function(x){x/nat.goalie$Played}))
nat.goalie <- cbind(nat.goalie[, c(1:2, 6, 8)], nat.gl.1)
nat.goalie.m <- merge(nat.goalie, wt, by = "cluster")
nat.gl.impact <- ddply(nat.goalie.m, .(cluster, NAME), transform, Impact = SV*SV.w + GC*GC.w + FC*FC.w + Cards*Cards.w )
nat.gl.team.impact <- ddply(nat.gl.impact, .(National.Teams), summarize, gl.Impact = mean(Impact))
nat.gl.team.impact.reordered <- nat.gl.team.impact[order(nat.gl.team.impact$gl.Impact, decreasing = T), ]
qplot(reorder(National.Teams,gl.Impact),data=nat.gl.team.impact.reordered,weight=gl.Impact,xlab="National Teams",ylab="Impact_Goalkeepers")+coord_flip()
=============================================================
#### Club Player Impact
=============================================================
player <- merge(nat_pl.sub, club_player, by = "NAME")
club_pl <- ddply(player[,-c(3:13)], .(NAME, National.Teams), summarize, GS=sum(GS.y),SB=sum(SB.y),G=sum(G.y),SH = sum(SH.y), SG = sum(SG.y),A = sum(A.y), FC=sum(FC.y),FS=sum(FS.y),YC=sum(YC.y),RC=sum(RC.y) )
club_pl$Played <- club_pl$GS + club_pl$SB
club_pl.sub <- subset(club_pl, Played > 0)
club_pl.sub$Cards <- club_pl.sub$YC + club_pl.sub$RC
### Clustering
club_pl.s <- as.data.frame(apply(club_pl.sub[, -c(1:4, 6, 10:13)], 2, function(x){round(x/club_pl.sub$Played, 4)}))
#club_pl.s$Played <- club_pl.sub$Played
d <- dist(club_pl.s)
k <- kmeans(d, 3)
club_pl.sub$cluster <- k$cluster
Players <- data.frame(Name = club_pl.sub$NAME, Cluster = k$cluster)
club_pl.new <- subset(club_pl.sub, select = G:cluster)
club_pl.new <- as.data.frame(apply(club_pl.new[, -c(2,6:9, 11)], 2, function(x){x/club_pl.new$Played}))
#club_pl.new$Played <- club_pl.sub$Played
club_pl.new$cluster <- club_pl.sub$cluster
ggpcp(data = club_pl.new, vars = names(club_pl.new)[c(1:5)]) + geom_line(aes(color = factor(cluster))) + facet_wrap( ~ cluster, nrow = 3 )
mean.club_pl <- ddply(club_pl.new, .(cluster), summarize, G = mean(G), SG = mean(SG), A = mean(A), FC = mean(FC), Cards = mean(Cards))
#ggpcp(data = mean.club_pl, vars = names(mean.club_pl[2:6])) + geom_line(aes(color = factor(cluster)))
sum.wt <- as.numeric(apply(mean.club_pl[, -c(1)], 2, sum))
wt <- ddply(mean.club_pl, .(cluster), summarize, G.w = G/sum.wt[1], SG.w = SG/sum.wt[2], A.w = A/sum.wt[3], FC.w = FC/sum.wt[4], Cards.w = Cards/sum.wt[5])
club.players <- club_pl.sub[, -c(3:4, 6, 10:12)]
club.pl.1 <- as.data.frame(apply(club.players[, -c(1:2, 7, 9)], 2, function(x){x/club.players$Played}))
club.players <- cbind(club.players[, c(1:2, 7, 9)], club.pl.1)
club.players.m <- merge(club.players, wt, by = "cluster")
club.impact <- ddply(club.players.m, .(cluster, NAME), transform, Impact = G*G.w + SG*SG.w + A*A.w + FC*FC.w + Cards*Cards.w)
club.team.impact <- ddply(club.impact, .(National.Teams), summarize, Impact = mean(Impact))
no.players <- ddply(club_pl.sub, .(National.Teams), summarize, l = length(NAME))
club.team.imp <- merge(no.players, club.team.impact, by = "National.Teams")
club.team.impact <- ddply(club.team.imp, .(National.Teams), summarize, Impact = Impact + 5*l/sum(no.players$l))
club.team.impact.ordered <- club.team.impact[order(club.team.impact$Impact, decreasing = T), ]
qplot(reorder(National.Teams,Impact),data=club.team.impact.ordered,weight=Impact)+coord_flip()
#clus1 <- subset(club.impact,cluster==1)
#clus2 <- subset(club.impact,cluster==2)
#clus3 <- subset(club.impact,cluster==3)
#clus2[which.max(clus2$Impact),]
#clus2[which.max(clus2$G),]
#clus2[which.max(clus2$A),]
#clus2[which.max(clus2$FC),]
#clus3[which.max(clus3$Impact),]
#clus3[which.max(clus3$G),]
#clus3[which.max(clus3$A),]
#clus3[which.max(clus3$FC),]
#clus1[which.max(clus1$Impact),]
#clus1[which.max(clus1$G),]
#clus1[which.max(clus1$A),]
#clus1[which.max(clus1$FC),]
=============================================================
#### Club Goalie Impact
=============================================================
goalie <- merge(Best.goalie.by.nat, club_goalie, by = "NAME")
club_gl <- ddply(goalie[,-c(3, 15:16)], .(NAME, National.Teams), summarize, GS=sum(GS),SB=sum(SB),SV = sum(SV), GC=sum(GC),FC = sum(FC), FS=sum(FS),YC=sum(YC),RC=sum(RC) )
club_gl$Played <- club_gl$GS + club_gl$SB
club_gl.sub <- subset(club_gl, Played > 0)
club_gl.sub$Cards <- club_gl.sub$YC + club_gl.sub$RC
#club_gl.sub$GC <- - club_gl.sub$GC
### Clustering
club_gl.s <- as.data.frame(apply(club_gl.sub[, -c(1:4, 8:11)], 2, function(x){round(x/club_gl.sub$Played, 4)}))
#club_pl.s$Played <- club_pl.sub$Played
d <- dist(club_gl.s)
k <- kmeans(d, 2)
club_gl.sub$cluster <- k$cluster
Club.Goalie <- data.frame(Name = club_gl.sub$NAME, Cluster = k$cluster)
club_gl.new <- subset(club_gl.sub, select = SV:cluster)
club_gl.new <- as.data.frame(apply(club_gl.new[, -c(4:7,9)], 2, function(x){x/club_gl.new$Played}))
club_gl.new$Played <- club_gl.sub$Played
club_gl.new$cluster <- club_gl.sub$cluster
ggpcp(data = club_gl.new, vars = names(club_gl.new)[c(1:4)]) + geom_line(aes(color = factor(cluster))) + facet_wrap( ~ cluster, nrow = 3 )
mean.club_gl <- ddply(club_gl.new, .(cluster), summarize, SV = mean(SV), GC = mean(GC), FC = mean(FC), Cards = mean(Cards))
#ggpcp(data = mean.club_gl, vars = names(mean.club_gl[2:5])) + geom_line(aes(color = factor(cluster)))
sum.wt <- as.numeric(apply(mean.club_gl[, -c(1)], 2, sum))
wt <- ddply(mean.club_gl, .(cluster), summarize, SV.w = SV/sum.wt[1], GC.w = GC/sum.wt[2], FC.w = FC/sum.wt[3], Cards.w = Cards/sum.wt[4])
club.goalie <- club_gl.sub[, -c(3:4, 8:10)]
club.gl.1 <- as.data.frame(apply(club.goalie[, -c(1:2, 6, 8)], 2, function(x){x/club.goalie$Played}))
club.goalie <- cbind(club.goalie[, c(1:2, 6, 8)], club.gl.1)
club.goalie.m <- merge(club.goalie, wt, by = "cluster")
club.gl.impact <- ddply(club.goalie.m, .(cluster, NAME), transform, Impact =SV*SV.w + GC*GC.w + FC*FC.w + Cards*Cards.w)
club.gl.team.impact <- ddply(club.gl.impact, .(National.Teams), summarize, Impact = mean(Impact))
club.gl.team.impact.reordered <- club.gl.team.impact[order(club.gl.team.impact$Impact, decreasing = T), ]
qplot(reorder(National.Teams,Impact),data=club.gl.team.impact.reordered,weight=Impact,xlab="National Teams",ylab="Impact_Goalkeepers")+coord_flip()
#clus1 <- subset(club.goalie,cluster==1)
#clus2 <- subset(club.goalie,cluster==2)
#clus1[which.max(clus1$SV),]
#clus1[which.min(clus1$GC),]
#clus1[which.max(clus1$FC),]
#clus2[which.max(clus2$FC),]
#clus2[which.max(clus2$SV),]
#clus2[which.min(clus2$GC),]
=============================================================
#### Final Impact
=============================================================
no.nat <- match(nat.team.impact$National.Teams, club.team.impact$National.Teams, nomatch = 0 )
club.team.impact <- rbind(club.team.impact, data.frame(National.Teams = nat.team.impact$National.Teams[which(no.nat == 0)], Impact = 0))
final.pl.impact <- merge(nat.team.impact, club.team.impact, by = "National.Teams")
no.club <- match(nat.gl.team.impact$National.Teams, club.gl.team.impact$National.Teams, nomatch = 0 )
club.gl.team.impact <- rbind(club.gl.team.impact, data.frame(National.Teams = nat.gl.team.impact$National.Teams[which(no.club == 0)], Impact = 0))
final.gl.impact <- merge(nat.gl.team.impact, club.gl.team.impact, by = "National.Teams")
final.pl.impact$Pl.impact <- 0.3*final.pl.impact$Impact.x + 0.7*final.pl.impact$Impact.y
final.gl.impact$Goalie.impact <- 0.6*final.gl.impact$gl.Impact + 0.4*final.gl.impact$Impact
WC.impact <- merge(final.pl.impact, final.gl.impact, by = "National.Teams")
WC.impact$Final.Impact <- (10/11)*WC.impact$Pl.impact + (1/11)*WC.impact$Goalie.impact
head(WC.impact[order(WC.impact$Final.Impact, decreasing = T),c(1,8)],16)
=============================================================
#### Best Players
=============================================================
cl.impact <- subset(club.impact, Played > 20)
#cl.impact[order(cl.impact$Impact, decreasing = T), ][1:15, c(2,3,4,15)]
nt.impact <- subset(nat.impact, Played > 7)
#nt.impact[order(nt.impact$Impact, decreasing = T), ][1:15, c(2,3,4,15) ]
best.player <- merge(cl.impact, nt.impact, by = c("National.Teams", "NAME"))
best.player$Total.impact <- 0.3*best.player$Impact.x + 0.7*best.player$Impact.y
best.player[order(best.player$Total.impact, decreasing = T), ][1:20,c(1,2,29) ]
=============================================================
#### Best Goalkeeper
=============================================================
cl.gl.impact <- subset(club.gl.impact, Played > 20)
#cl.gl.impact[order(cl.gl.impact$Impact, decreasing = T), ][1:7, c(2,3,13)]
nt.gl.impact <- subset(nat.gl.impact, Played > 5)
#nt.gl.impact[order(nt.gl.impact$Impact, decreasing = T), ][1:7, c(2,3,13) ]
best.player <- merge(cl.gl.impact, nt.gl.impact, by = c("National.Teams", "NAME"))
best.player$Total.impact <- 0.5*best.player$Impact.x + 0.5*best.player$Impact.y
best.player[order(best.player$Total.impact, decreasing = T), ][1:7,c(1,2,25) ]