structure(list(Date = structure(c(4L, 4L, 4L, 4L, 4L, 4L, 4L,
5L, 5L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 9L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 3L), .Label = c("13/09/14", "14/09/14", "15/09/14",
"16/08/14", "17/08/14", "18/08/14", "23/08/14", "24/08/14", "25/08/14",
"30/08/14", "31/08/14"), class = "factor"), HomeTeam = structure(c(1L,
8L, 11L, 13L, 15L, 19L, 20L, 9L, 12L, 3L, 2L, 4L, 5L, 6L, 14L,
17L, 7L, 16L, 18L, 10L, 3L, 6L, 10L, 12L, 13L, 17L, 20L, 2L,
8L, 18L, 1L, 4L, 5L, 9L, 14L, 15L, 16L, 19L, 11L, 7L), .Label = c("Arsenal",
"Aston Villa", "Burnley", "Chelsea", "Crystal Palace", "Everton",
"Hull", "Leicester", "Liverpool", "Man City", "Man United", "Newcastle",
"QPR", "Southampton", "Stoke", "Sunderland", "Swansea", "Tottenham",
"West Brom", "West Ham"), class = "factor"), AwayTeam = structure(c(5L,
6L, 17L, 7L, 2L, 16L, 18L, 14L, 10L, 4L, 12L, 8L, 20L, 1L, 19L,
3L, 15L, 11L, 13L, 9L, 11L, 4L, 15L, 5L, 16L, 19L, 14L, 7L, 1L,
9L, 10L, 17L, 3L, 2L, 12L, 8L, 18L, 6L, 13L, 20L), .Label = c("Arsenal",
"Aston Villa", "Burnley", "Chelsea", "Crystal Palace", "Everton",
"Hull", "Leicester", "Liverpool", "Man City", "Man United", "Newcastle",
"QPR", "Southampton", "Stoke", "Sunderland", "Swansea", "Tottenham",
"West Brom", "West Ham"), class = "factor"), FTR = structure(c(3L,
2L, 1L, 1L, 1L, 2L, 1L, 3L, 1L, 1L, 2L, 3L, 1L, 2L, 2L, 3L, 2L,
2L, 3L, 3L, 2L, 1L, 1L, 2L, 3L, 3L, 1L, 3L, 2L, 1L, 2L, 3L, 2L,
1L, 3L, 1L, 2L, 1L, 3L, 2L), .Label = c("A", "D", "H"), class = "factor"),
Referee = structure(c(4L, 10L, 9L, 3L, 1L, 12L, 2L, 8L, 7L,
11L, 9L, 6L, 8L, 5L, 15L, 3L, 4L, 7L, 1L, 11L, 2L, 4L, 6L,
10L, 16L, 14L, 9L, 8L, 1L, 13L, 8L, 5L, 9L, 6L, 2L, 11L,
3L, 1L, 13L, 7L), .Label = c("A Taylor", "C Foy", "C Pawson",
"J Moss", "K Friend", "L Mason", "M Atkinson", "M Clattenburg",
"M Dean", "M Jones", "M Oliver", "N Swarbrick", "P Dowd",
"P Tierney", "R East", "R Madley"), class = "factor")), .Names = c("Date",
"HomeTeam", "AwayTeam", "FTR", "Referee"), row.names = c(NA,
40L), class = "data.frame")
在上面的数据集中,我试图找出为每支球队提供最多比赛次数的裁判。例如,在主场比赛和客场比赛中,哪个家伙最适合阿斯顿维拉。
很抱歉我对我的问题直言不讳。我做了一个尝试。 为了找出裁判J Moss为阿森纳裁判多少次,我试过这个,
awayref<-nrow(awayref<-(filter(fd,fd$Referee=='J Moss',fd$AwayTeam=='Arsenal')))
homeref<-nrow(hf<-(filter(fd,fd$Referee=='J Moss',fd$HomeTeam=='Arsenal')))
View(total<-homeref+awayref)
我需要一些帮助来循环它以包括所有裁判和所有球队。
答案 0 :(得分:2)
我们可以做到
tbl1 <- table(df1$Referee)
tbl1[which.max(tbl1)]