About

We will create two ELO rating tables in football (soccer). The first will be an ELO table for England’s top 3 divisions from 2015 to present. The second will be an ELO table of every international team that has played since 1872 to the present.

Using R, we will calculate Elo ratings, a dynamic ranking system that updates team strength based on game results.

Exercise 1, Part A: Extract English League Match Data

Extract match results for English leagues from 2015 to 2025. This function allows us to specify country, gender, season years, and league tiers. This takes 4-5 minutes.

pl_2015_25_results <- fb_match_results(
  country = "ENG", 
  gender = "M", 
  season_end_year = 2015:2025, 
  tier = c("1st", "2nd", "3rd")
)

# Preview the data
head(pl_2015_25_results)
##   Competition_Name Gender Country Season_End_Year        Round Wk Day
## 1 EFL Championship      M     ENG            2015 Championship  1 Fri
## 2 EFL Championship      M     ENG            2015 Championship  1 Sat
## 3 EFL Championship      M     ENG            2015 Championship  1 Sat
## 4 EFL Championship      M     ENG            2015 Championship  1 Sat
## 5 EFL Championship      M     ENG            2015 Championship  1 Sat
## 6 EFL Championship      M     ENG            2015 Championship  1 Sat
##         Date  Time          Home HomeGoals            Away AwayGoals Attendance
## 1 2014-08-08 19:45     Blackburn         1    Cardiff City         1      15625
## 2 2014-08-09 15:00       Watford         3          Bolton         0      15546
## 3 2014-08-09 15:00      Brighton         0  Sheffield Weds         1      26993
## 4 2014-08-09 15:00 Middlesbrough         2 Birmingham City         0      18371
## 5 2014-08-09 15:00     Brentford         1    Charlton Ath         1       9690
## 6 2014-08-09 15:00  Derby County         1   Rotherham Utd         0      30105
##                                    Venue          Referee Notes
## 1                             Ewood Park      Andy Madley      
## 2                  Vicarage Road Stadium     Carl Boyeson      
## 3 The American Express Community Stadium  James Linington      
## 4                      Riverside Stadium Graham Salisbury      
## 5                           Griffin Park     James Adcock      
## 6                           iPro Stadium    Andrew D'Urso      
##                                                                                                        MatchURL
## 1                https://fbref.com/en/matches/e20ac0bc/Blackburn-Rovers-Cardiff-City-August-8-2014-Championship
## 2                     https://fbref.com/en/matches/061a69cf/Watford-Bolton-Wanderers-August-9-2014-Championship
## 3 https://fbref.com/en/matches/3ff54b92/Brighton-and-Hove-Albion-Sheffield-Wednesday-August-9-2014-Championship
## 4                https://fbref.com/en/matches/625cda2d/Middlesbrough-Birmingham-City-August-9-2014-Championship
## 5                  https://fbref.com/en/matches/62cfd9a7/Brentford-Charlton-Athletic-August-9-2014-Championship
## 6                https://fbref.com/en/matches/720fee88/Derby-County-Rotherham-United-August-9-2014-Championship
##   Home_xG Away_xG
## 1      NA      NA
## 2      NA      NA
## 3      NA      NA
## 4      NA      NA
## 5      NA      NA
## 6      NA      NA

Exercise 1, Part B: Clean the Data

Clean the data set by removing unnecessary columns and drop rows with missing values.

pl_2015_25_results_clean <- pl_2015_25_results %>%
  select(-Round, -Notes, -Attendance, -Gender, -Day, -Venue, -Referee, -MatchURL) %>%
  drop_na()

# Preview cleaned data
head(pl_2015_25_results_clean)
##   Competition_Name Country Season_End_Year Wk       Date  Time         Home
## 1 EFL Championship     ENG            2019  1 2018-08-03 20:00      Reading
## 2 EFL Championship     ENG            2019  1 2018-08-04 15:00 Ipswich Town
## 3 EFL Championship     ENG            2019  1 2018-08-04 15:00      Preston
## 4 EFL Championship     ENG            2019  1 2018-08-04 15:00    West Brom
## 5 EFL Championship     ENG            2019  1 2018-08-04 15:00    Brentford
## 6 EFL Championship     ENG            2019  1 2018-08-04 15:00     Millwall
##   HomeGoals          Away AwayGoals Home_xG Away_xG
## 1         1  Derby County         2     0.9     0.7
## 2         2     Blackburn         2     0.6     1.8
## 3         1           QPR         0     0.6     0.5
## 4         1        Bolton         2     1.5     1.2
## 5         5 Rotherham Utd         1     2.5     0.6
## 6         2 Middlesbrough         2     2.2     1.8

Exercise 1, Part C: Prepare Data for Elo Calculation

Prepare the data for Elo ratings by selecting the columns Week (Wk), Home, Away, HomeGoals, and AwayGoals. We create a new column ‘Result’ that represents the match outcome, with 1 for a home win, 0 for an away win, and 0.5 for a draw.

elo_data <- pl_2015_25_results_clean %>%
  select(Wk, Home, Away, HomeGoals, AwayGoals) %>%
  mutate(Result = case_when(
    HomeGoals > AwayGoals ~ 1,   # Home team wins
    HomeGoals < AwayGoals ~ 0,   # Away team wins
    TRUE ~ 0.5                   # Draw
  ))

# Finalise the data format for Elo calculation
elo_data_final <- elo_data %>% 
  select(Wk, Home, Away, Result) %>%
  mutate(Wk = as.numeric(Wk))

# Preview prepared data
head(elo_data_final)
##   Wk         Home          Away Result
## 1  1      Reading  Derby County    0.0
## 2  1 Ipswich Town     Blackburn    0.5
## 3  1      Preston           QPR    1.0
## 4  1    West Brom        Bolton    0.0
## 5  1    Brentford Rotherham Utd    1.0
## 6  1     Millwall Middlesbrough    0.5

Exercise 1, Part D: Calculate Elo Ratings for English League Matches

Calculate Elo ratings using a K-factor of 50. The Elo function requires initial ratings (init) and an adjustment factor (k). Here we use 1500 as the initial Elo rating for each team.

elo_ratings <- elo(elo_data_final, init = 1500, k = 50, history = TRUE)

# Display Elo ratings
print(elo_ratings)
## 
## Elo Ratings For 55 Players Playing 6205 Games
## 
##             Player Rating Games Win Draw Loss Lag
## 1  Manchester City   1934   275 209   34   32   8
## 2        Liverpool   1878   275 181   60   34   8
## 3          Arsenal   1806   275 153   51   71   8
## 4    Newcastle Utd   1728   275 100   70  105   8
## 5      Aston Villa   1725   245 101   55   89   0
## 6   Crystal Palace   1715   275  84   76  115   8
## 7        Tottenham   1706   275 144   47   84   8
## 8         West Ham   1686   275  98   63  114   8
## 9          Chelsea   1685   275 136   65   74   8
## 10  Manchester Utd   1653   275 143   62   70   8
## 11        Brighton   1640   275  82   89  104   8
## 12       Brentford   1602   260 106   68   86   0
## 13   Sheffield Utd   1596   264 106   54  104   0
## 14         Everton   1568   275  92   67  116   8
## 15     Bournemouth   1564   291 107   66  118   0
## 16             QPR   1534   288  97   67  124   0
## 17          Fulham   1533   253  93   57  103   0
## 18      Luton Town   1522   234  82   59   93   0
## 19  Wigan Athletic   1518   138  38   42   58   0
## 20       Blackburn   1509   288 106   72  110   0
## 21          Wolves   1502   237  82   55  100   8
## 22  Leicester City   1489   283 121   56  106   0
## 23    Leeds United   1489   264 120   57   87   0
## 24      Stoke City   1488   326  98   93  135   0
## 25    Ipswich Town   1478   101  33   32   36   0
## 26         Burnley   1471   286  97   79  110   0
## 27   Oxford United   1471    12   3    5    4  34
## 28         Watford   1467   302 101   74  127   0
## 29    Huddersfield   1466   306  83   84  139   0
## 30     Southampton   1464   283  84   71  128   0
## 31   Middlesbrough   1461   288 118   68  102   0
## 32    Swansea City   1459   326 119   88  119   0
## 33        Millwall   1448   288  99   89  100   0
## 34         Wycombe   1442    46  11   10   25   0
## 35    Norwich City   1439   272 108   63  101   0
## 36      Sunderland   1437   104  43   24   37   0
## 37       West Brom   1435   318 118   94  106   0
## 38   Coventry City   1435   196  69   58   69   0
## 39 Nott'ham Forest   1434   269  92   82   95   0
## 40  Sheffield Weds   1419   196  62   49   85   0
## 41         Preston   1412   288 106   74  108   0
## 42        Barnsley   1403   138  41   34   63   0
## 43    Cardiff City   1398   280  97   60  123   0
## 44      Portsmouth   1390    12   1    5    6  34
## 45    Derby County   1388   196  66   54   76   0
## 46 Plymouth Argyle   1367    58  16   15   27   0
## 47    Bristol City   1351   288 101   73  114   0
## 48       Hull City   1349   242  79   63  100   0
## 49       Blackpool   1347    92  27   23   42   0
## 50    Charlton Ath   1336    46  12   12   22   0
## 51   P'borough Utd   1327    46   9   10   27   0
## 52   Rotherham Utd   1309   184  35   54   95   0
## 53         Reading   1300   230  70   60  100   0
## 54 Birmingham City   1294   276  77   82  117   0
## 55          Bolton   1235    45   8    8   29   0

Exercise 1, Part E: Extract Elo Ratings History

Extract the Elo ratings history to see how ratings change over time. Convert the Elo history data to a data frame.

elo_history <- as.data.frame(elo_ratings$history)

# View the first few rows of the Elo history data
head(elo_history)
##                 1.Rating 2.Rating 3.Rating 4.Rating 5.Rating 6.Rating 7.Rating
## Arsenal             1600 1585.615 1553.928 1704.192 1719.923 1695.005 1760.973
## Aston Villa         1425 1543.024 1592.921 1535.785 1604.769 1587.307 1554.698
## Barnsley            1500 1467.908 1450.242 1399.721 1386.820 1373.346 1358.200
## Birmingham City     1575 1560.219 1479.738 1531.675 1421.356 1418.099 1414.562
## Blackburn           1550 1546.947 1643.895 1568.497 1498.271 1421.484 1550.088
## Blackpool           1525 1464.424 1419.537 1453.454 1420.890 1467.963 1410.489
##                 8.Rating 9.Rating 10.Rating 11.Rating 12.Rating 13.Rating
## Arsenal         1684.439 1726.343  1722.672  1647.961  1588.898  1673.163
## Aston Villa     1646.374 1583.115  1518.517  1466.819  1475.389  1628.895
## Barnsley        1385.314 1375.533  1346.896  1338.174  1365.160  1336.916
## Birmingham City 1443.390 1461.738  1420.490  1452.179  1407.751  1422.711
## Blackburn       1434.356 1376.043  1433.573  1374.379  1457.893  1448.959
## Blackpool       1462.607 1462.419  1428.096  1425.497  1392.462  1431.453
##                 14.Rating 15.Rating 16.Rating 17.Rating 18.Rating 19.Rating
## Arsenal          1664.890  1640.909  1700.343  1678.849  1736.077  1681.802
## Aston Villa      1574.165  1657.289  1669.632  1634.536  1616.657  1579.532
## Barnsley         1284.329  1311.236  1320.023  1323.317  1315.690  1368.846
## Birmingham City  1514.089  1500.027  1463.363  1447.053  1383.653  1393.917
## Blackburn        1436.890  1576.684  1530.403  1559.215  1549.902  1479.540
## Blackpool        1491.017  1505.480  1448.445  1481.990  1510.757  1480.419
##                 20.Rating 21.Rating 22.Rating 23.Rating 24.Rating 25.Rating
## Arsenal          1690.974  1755.008  1609.249  1604.205  1750.767  1721.599
## Aston Villa      1620.902  1636.581  1531.588  1599.251  1597.809  1562.246
## Barnsley         1326.773  1358.108  1396.369  1418.275  1408.706  1359.983
## Birmingham City  1464.455  1395.969  1353.374  1360.793  1383.115  1336.359
## Blackburn        1512.105  1508.874  1458.127  1472.370  1358.808  1328.701
## Blackpool        1420.714  1362.520  1341.278  1371.148  1354.254  1327.381
##                 26.Rating 27.Rating 28.Rating 29.Rating 30.Rating 31.Rating
## Arsenal          1827.446  1798.656  1815.294  1793.891  1779.948  1677.787
## Aston Villa      1558.438  1545.311  1588.393  1555.055  1582.537  1582.517
## Barnsley         1329.246  1343.453  1311.377  1318.962  1314.232  1338.981
## Birmingham City  1270.525  1322.940  1333.041  1319.021  1385.037  1466.652
## Blackburn        1428.332  1464.790  1515.753  1526.662  1378.865  1329.357
## Blackpool        1378.357  1386.818  1412.440  1406.702  1417.960  1407.418
##                 32.Rating 33.Rating 34.Rating 35.Rating 36.Rating 37.Rating
## Arsenal          1682.448  1589.701  1731.939  1743.464  1715.915  1667.063
## Aston Villa      1494.239  1521.745  1559.335  1592.413  1615.781  1729.223
## Barnsley         1380.631  1419.245  1499.288  1553.937  1506.892  1497.230
## Birmingham City  1436.078  1492.118  1383.912  1313.232  1340.569  1303.212
## Blackburn        1329.048  1399.428  1415.391  1438.283  1363.723  1370.072
## Blackpool        1368.815  1407.044  1356.047  1408.122  1402.713  1457.597
##                 38.Rating 39.Rating 40.Rating 41.Rating 42.Rating 43.Rating
## Arsenal          1805.924  1805.924  1805.924  1805.924  1805.924  1805.924
## Aston Villa      1747.852  1754.074  1760.580  1764.924  1770.459  1772.994
## Barnsley         1501.815  1467.741  1504.811  1466.275  1443.754  1431.673
## Birmingham City  1293.022  1343.249  1454.254  1427.099  1353.169  1377.663
## Blackburn        1408.905  1270.293  1274.818  1347.244  1402.733  1419.926
## Blackpool        1436.743  1382.584  1352.631  1331.311  1341.193  1353.353
##                 44.Rating 45.Rating 46.Rating 1.Games 2.Games 3.Games 4.Games
## Arsenal          1805.924  1805.924  1805.924       8      16      24      32
## Aston Villa      1781.231  1767.030  1724.741       7      14      21      28
## Barnsley         1403.036  1376.002  1402.581       3       6       9      12
## Birmingham City  1386.894  1332.461  1293.990       6      12      18      24
## Blackburn        1438.656  1417.091  1508.732       7      14      21      28
## Blackpool        1393.264  1341.336  1347.258       2       4       6       8
##                 5.Games 6.Games 7.Games 8.Games 9.Games 10.Games 11.Games
## Arsenal              40      48      56      64      72       79       86
## Aston Villa          35      42      49      56      63       69       75
## Barnsley             15      18      21      24      27       30       33
## Birmingham City      30      36      42      48      54       60       66
## Blackburn            35      42      49      56      63       70       77
## Blackpool            10      12      14      16      18       20       22
##                 12.Games 13.Games 14.Games 15.Games 16.Games 17.Games 18.Games
## Arsenal               93      100      107      114      121      128      135
## Aston Villa           81       87       93       99      105      111      117
## Barnsley              36       39       42       45       48       51       54
## Birmingham City       72       78       84       90       96      102      108
## Blackburn             84       90       96      102      108      114      120
## Blackpool             24       26       28       30       32       34       36
##                 19.Games 20.Games 21.Games 22.Games 23.Games 24.Games 25.Games
## Arsenal              142      149      156      163      170      177      184
## Aston Villa          123      129      135      141      147      153      159
## Barnsley              57       60       63       66       69       72       75
## Birmingham City      114      120      126      132      138      144      150
## Blackburn            126      132      138      144      150      156      162
## Blackpool             38       40       42       44       46       48       50
##                 26.Games 27.Games 28.Games 29.Games 30.Games 31.Games 32.Games
## Arsenal              191      198      205      212      219      226      233
## Aston Villa          165      171      177      183      189      195      201
## Barnsley              78       81       84       87       90       93       96
## Birmingham City      156      162      168      174      180      186      192
## Blackburn            168      174      180      186      192      198      204
## Blackpool             52       54       56       58       60       62       64
##                 33.Games 34.Games 35.Games 36.Games 37.Games 38.Games 39.Games
## Arsenal              240      247      254      261      268      275      275
## Aston Villa          207      213      219      225      231      237      238
## Barnsley              99      102      105      108      111      114      117
## Birmingham City      198      204      210      216      222      228      234
## Blackburn            210      216      222      228      234      240      246
## Blackpool             66       68       70       72       74       76       78
##                 40.Games 41.Games 42.Games 43.Games 44.Games 45.Games 46.Games
## Arsenal              275      275      275      275      275      275      275
## Aston Villa          239      240      241      242      243      244      245
## Barnsley             120      123      126      129      132      135      138
## Birmingham City      240      246      252      258      264      270      276
## Blackburn            252      258      264      270      276      282      288
## Blackpool             80       82       84       86       88       90       92
##                 1.Lag 2.Lag 3.Lag 4.Lag 5.Lag 6.Lag 7.Lag 8.Lag 9.Lag 10.Lag
## Arsenal             0     0     0     0     0     0     0     0     0      0
## Aston Villa         0     0     0     0     0     0     0     0     0      0
## Barnsley            0     0     0     0     0     0     0     0     0      0
## Birmingham City     0     0     0     0     0     0     0     0     0      0
## Blackburn           0     0     0     0     0     0     0     0     0      0
## Blackpool           0     0     0     0     0     0     0     0     0      0
##                 11.Lag 12.Lag 13.Lag 14.Lag 15.Lag 16.Lag 17.Lag 18.Lag 19.Lag
## Arsenal              0      0      0      0      0      0      0      0      0
## Aston Villa          0      0      0      0      0      0      0      0      0
## Barnsley             0      0      0      0      0      0      0      0      0
## Birmingham City      0      0      0      0      0      0      0      0      0
## Blackburn            0      0      0      0      0      0      0      0      0
## Blackpool            0      0      0      0      0      0      0      0      0
##                 20.Lag 21.Lag 22.Lag 23.Lag 24.Lag 25.Lag 26.Lag 27.Lag 28.Lag
## Arsenal              0      0      0      0      0      0      0      0      0
## Aston Villa          0      0      0      0      0      0      0      0      0
## Barnsley             0      0      0      0      0      0      0      0      0
## Birmingham City      0      0      0      0      0      0      0      0      0
## Blackburn            0      0      0      0      0      0      0      0      0
## Blackpool            0      0      0      0      0      0      0      0      0
##                 29.Lag 30.Lag 31.Lag 32.Lag 33.Lag 34.Lag 35.Lag 36.Lag 37.Lag
## Arsenal              0      0      0      0      0      0      0      0      0
## Aston Villa          0      0      0      0      0      0      0      0      0
## Barnsley             0      0      0      0      0      0      0      0      0
## Birmingham City      0      0      0      0      0      0      0      0      0
## Blackburn            0      0      0      0      0      0      0      0      0
## Blackpool            0      0      0      0      0      0      0      0      0
##                 38.Lag 39.Lag 40.Lag 41.Lag 42.Lag 43.Lag 44.Lag 45.Lag 46.Lag
## Arsenal              0      1      2      3      4      5      6      7      8
## Aston Villa          0      0      0      0      0      0      0      0      0
## Barnsley             0      0      0      0      0      0      0      0      0
## Birmingham City      0      0      0      0      0      0      0      0      0
## Blackburn            0      0      0      0      0      0      0      0      0
## Blackpool            0      0      0      0      0      0      0      0      0

Exercise 2: Calculating Elo Ratings for International Matches

Now that we have computed Elo ratings for English league matches, let’s apply similar calculations to international matches. We’ll read in a dataset of all historical international matches from 1872 and prepare it for Elo calculations.

Exercise 2, Part A: Load International Matches Data

Load the international matches dataset. This data should contain details of match scores, and we will select relevant columns and create a Result column for Elo calculations. NOTE: Ensure that ‘results.csv’ is in your working directory or provide the full path to the file.

results <- read_csv("results.csv")
## Rows: 47777 Columns: 9
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (5): home_team, away_team, tournament, city, country
## dbl  (2): home_score, away_score
## lgl  (1): neutral
## date (1): date
## 
## ℹ 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.
# Preview the loaded data
head(results)
## # A tibble: 6 × 9
##   date       home_team away_team home_score away_score tournament city   country
##   <date>     <chr>     <chr>          <dbl>      <dbl> <chr>      <chr>  <chr>  
## 1 1872-11-30 Scotland  England            0          0 Friendly   Glasg… Scotla…
## 2 1873-03-08 England   Scotland           4          2 Friendly   London England
## 3 1874-03-07 Scotland  England            2          1 Friendly   Glasg… Scotla…
## 4 1875-03-06 England   Scotland           2          2 Friendly   London England
## 5 1876-03-04 Scotland  England            3          0 Friendly   Glasg… Scotla…
## 6 1876-03-25 Scotland  Wales              4          0 Friendly   Glasg… Scotla…
## # ℹ 1 more variable: neutral <lgl>

Exercise 2, Part B: Clean the International Matches Data

Clean the international matches dataset by removing columns that are not required for Elo calculations.

results_clean <- results %>%
  select(-tournament, -city, -country, -neutral)

# Preview the cleaned data
head(results_clean)
## # A tibble: 6 × 5
##   date       home_team away_team home_score away_score
##   <date>     <chr>     <chr>          <dbl>      <dbl>
## 1 1872-11-30 Scotland  England            0          0
## 2 1873-03-08 England   Scotland           4          2
## 3 1874-03-07 Scotland  England            2          1
## 4 1875-03-06 England   Scotland           2          2
## 5 1876-03-04 Scotland  England            3          0
## 6 1876-03-25 Scotland  Wales              4          0

Exercise 2, Part C: Prepare Data for International Elo Calculation

Prepare the data for Elo by creating a Result column, where: 1 indicates a home team win, 0 indicates an away team win, and 0.5 indicates a draw.

elo_data_international <- results_clean %>%
  mutate(Result = case_when(
    home_score > away_score ~ 1,    # Home team wins
    home_score < away_score ~ 0,    # Away team wins
    TRUE ~ 0.5                      # Draw
  ))

# Select the relevant columns for Elo calculations
elo_data_final_international <- elo_data_international %>%
  select(date, home_team, away_team, Result) %>%
  mutate(date = as.numeric(as.Date(date, "%Y-%m-%d")))

# Preview the prepared international match data
head(elo_data_final_international)
## # A tibble: 6 × 4
##     date home_team away_team Result
##    <dbl> <chr>     <chr>      <dbl>
## 1 -35460 Scotland  England      0.5
## 2 -35362 England   Scotland     1  
## 3 -34998 Scotland  England      1  
## 4 -34634 England   Scotland     0.5
## 5 -34270 Scotland  England      1  
## 6 -34249 Scotland  Wales        1

Exercise 2, Part D: Calculate Elo Ratings for International Matches

Calculate Elo ratings for international matches using the same K-factor and initial rating as before.

elo_ratings_international <- elo(elo_data_final_international, init = 1500, k = 50, history = TRUE)

# Display the international Elo ratings
print(elo_ratings_international)
## 
## Elo Ratings For 336 Players Playing 47777 Games
## 
##                               Player Rating Games Win Draw Loss   Lag
## 1                              Spain   2154   762 447  176  139     0
## 2                          Argentina   2130  1051 578  256  217     0
## 3                           Colombia   2055   622 251  172  199     0
## 4                             France   2041   912 462  193  257     1
## 5                            Germany   2024  1012 587  211  214     1
## 6                             Brazil   1994  1044 665  212  167     0
## 7                           Portugal   1993   679 339  155  185     0
## 8                              Italy   1979   868 462  241  165     1
## 9                            England   1972  1074 612  257  205     2
## 10                       Netherlands   1959   855 439  192  224     1
## 11                           Croatia   1946   380 199  102   79     0
## 12                             Japan   1942   784 381  162  241     0
## 13                           Austria   1921   843 355  181  307     2
## 14                           Belgium   1921   831 368  177  286     1
## 15                           Denmark   1914   854 391  180  283     0
## 16                              Iran   1902   598 341  141  116     0
## 17                           Ecuador   1887   575 176  148  251     0
## 18                           Uruguay   1884   952 420  233  299     0
## 19                            Turkey   1883   626 248  150  228     1
## 20                       South Korea   1869   994 530  249  215     0
## 21                    Basque Country   1869    58  38   11    9   532
## 22                            Greece   1865   613 233  152  228     2
## 23                           Morocco   1857   587 281  167  139     0
## 24                       Switzerland   1852   866 308  196  362     0
## 25                           Hungary   1850   989 465  218  306     1
## 26                            Serbia   1850   330 149   85   96     0
## 27                            Canada   1843   446 169  100  177     0
## 28                          Slovenia   1842   300 110   79  111     2
## 29                            Mexico   1841   978 500  224  254     0
## 30                        Uzbekistan   1831   338 163   67  108     0
## 31                            Poland   1829   875 376  221  278     0
## 32                            Russia   1822   727 372  192  163    12
## 33                           Ukraine   1820   322 144   92   86     1
## 34                            Jersey   1820   232 152   19   61   156
## 35                           Senegal   1817   615 282  165  168     0
## 36                    Czech Republic   1817   353 186   71   96     1
## 37                            Norway   1813   852 316  194  342     2
## 38                         Australia   1810   565 287  120  158     0
## 39                         Venezuela   1810   444 112   99  233     0
## 40                            Sweden   1797  1079 533  230  316     1
## 41                         Catalonia   1795    48  19   12   17   684
## 42                           Algeria   1791   590 269  157  164     1
## 43                          Paraguay   1787   768 268  204  296     0
## 44                             Egypt   1785   731 368  176  187     0
## 45                     United States   1782   762 337  159  266     0
## 46                             Wales   1779   710 228  160  322     1
## 47                          Slovakia   1776   351 142   84  125     1
## 48                              Peru   1775   699 229  171  299     0
## 49                         German DR   1770   298 140   66   92  6758
## 50                           Georgia   1766   291  94   61  136     1
## 51                           Romania   1754   749 327  193  229     0
## 52                              Iraq   1753   632 293  183  156     0
## 53                       Ivory Coast   1735   618 313  159  146     0
## 54                            Jordan   1734   456 170  126  160     0
## 55                        Costa Rica   1733   702 309  170  223     0
## 56                          Scotland   1729   835 392  181  262     0
## 57                            Panama   1720   514 170  125  219     0
## 58                           Albania   1718   382 104   81  197     1
## 59                    Czechoslovakia   1716   502 226  114  162  6322
## 60                             Qatar   1710   615 256  148  211     0
## 61                           Tunisia   1709   654 284  183  187     0
## 62                             Chile   1708   818 308  176  334     0
## 63                        Yugoslavia   1701   483 223   98  162  4611
## 64                         Andalusia   1697    13   8    4    1  1652
## 65                          Cameroon   1692   598 263  186  149     1
## 66                         Occitania   1687    33  19    6    8  1361
## 67                          Guernsey   1687   240 145   25   70   157
## 68                           Jamaica   1686   638 246  149  243     1
## 69               Republic of Ireland   1681   616 235  173  208     2
## 70                   Northern Cyprus   1680    34  20    7    7   819
## 71                           Bolivia   1678   515 114  116  285     0
## 72                          DR Congo   1678   502 194  141  167     0
## 73                       New Zealand   1675   400 166   72  162     1
## 74                          Ynys Môn   1666    65  35   11   19   156
## 75                              Mali   1664   554 226  145  183     0
## 76                           Iceland   1663   505 155   99  251     1
## 77                           Nigeria   1657   634 297  182  155     4
## 78                     Isle of Wight   1656    48  26    7   15   157
## 79                            Angola   1654   400 138  140  122     0
## 80                            Kernow   1652    12   7    2    3   155
## 81                   North Macedonia   1652   290  90   73  127     2
## 82                      Saudi Arabia   1647   710 338  164  208     0
## 83                       Isle of Man   1645    53  31    4   18   157
## 84                      South Africa   1640   460 204  140  116     0
## 85              United Arab Emirates   1638   592 239  145  208     0
## 86                      Burkina Faso   1636   442 152  119  171     2
## 87                   Iraqi Kurdistan   1635    27  13    8    6  1129
## 88                           Padania   1634    44  30    8    6   666
## 89                           Corsica   1623     9   4    4    1   978
## 90                              Oman   1620   520 199  128  193     0
## 91                            Kosovo   1619    88  32   20   36     0
## 92                          Abkhazia   1618    32  14   13    5   666
## 93                    County of Nice   1617     9   6    1    2  1275
## 94                           Bahrain   1616   564 201  152  211     0
## 95                  Northern Ireland   1616   691 179  157  355     0
## 96                        Kárpátalja   1611    11   5    5    1   819
## 97                           Finland   1608   798 209  163  426     2
## 98                          Honduras   1604   600 238  156  206     1
## 99                            Rhodes   1603    18  11    2    5  2059
## 100                            Haiti   1603   492 208  106  178     1
## 101                Equatorial Guinea   1598   162  48   35   79     1
## 102                           Israel   1595   484 174  113  197     1
## 103                        Guatemala   1591   534 192  136  206     0
## 104                       Cape Verde   1590   218  82   49   87     0
## 105                         Bulgaria   1588   719 258  184  277     0
## 106                        Yorkshire   1587     7   5    1    1   673
## 107                       Montenegro   1584   154  51   39   64     1
## 108                         Thailand   1583   842 324  202  316     7
## 109                          Galicia   1581    10   4    3    3  1143
## 110                          Artsakh   1577    11   6    2    3   666
## 111                     Ellan Vannin   1572    22  11    5    6   825
## 112                           Guinea   1571   526 196  148  182     0
## 113              Trinidad and Tobago   1562   729 316  156  257     1
## 114                 Arameans Suryoye   1561    10   5    2    3  1482
## 115                            Gabon   1556   390 134  112  144     0
## 116                       Mozambique   1552   359 113   94  152     1
## 117           Bosnia and Herzegovina   1546   267  98   60  109     1
## 118                        Maule Sur   1546     2   2    0    0   304
## 119                         Cascadia   1546     7   4    1    2   680
## 120                   Canary Islands   1543     4   3    0    1  2783
## 121                         Brittany   1542    12   6    3    3  1662
## 122                            Ghana   1542   658 308  172  178     0
## 123                           Panjab   1540    19   9    3    7   562
## 124                          Réunion   1536   124  53   22   49   144
## 125                          Belarus   1536   299  88   76  135     0
## 126                       Azerbaijan   1534   294  59   75  160     1
## 127                          Silesia   1532     8   3    2    3  2997
## 128                          Comoros   1531   130  29   31   70     0
## 129                           Biafra   1528     3   2    0    1   326
## 130                         Asturias   1528     1   1    0    0 15565
## 131                       Luxembourg   1526   452  48   61  343     0
## 132                            Sudan   1526   450 149  111  190     0
## 133                       Kazakhstan   1525   252  66   57  129     2
## 134                         Chameria   1525     7   3    2    2   168
## 135                           Zambia   1525   782 355  201  226     0
## 136                         Malaysia   1525   818 318  188  312     1
## 137                            Syria   1524   468 165  117  186     8
## 138                       Martinique   1522   325 145   83   97     0
## 139                           Surrey   1521     1   1    0    0   842
## 140               Parishes of Jersey   1521     3   2    0    1   672
## 141                         China PR   1520   700 344  152  204     0
## 142                       Donetsk PR   1518     6   2    2    2   920
## 143                         Felvidék   1517    12   5    2    5   967
## 144                          Moldova   1516   283  57   66  160     2
## 145                          Menorca   1516    25  11    6    8   157
## 146                            Libya   1514   372 139   85  148     4
## 147                      Elba Island   1514     1   1    0    0   295
## 148                          Armenia   1514   257  63   54  140     2
## 149                        Nicaragua   1513   208  49   24  135     1
## 150                        Indonesia   1513   710 274  140  296     0
## 151                           Crimea   1510     5   3    0    2  3009
## 152                    New Caledonia   1510   259 133   33   93     5
## 153                      North Korea   1509   382 161  104  117     0
## 154                         Suriname   1508   381 167   88  126     0
## 155                             Fiji   1507   257 115   44   98     5
## 156                    Central Spain   1503     2   1    0    1 15509
## 157                      Tamil Eelam   1502    24  12    0   12   150
## 158                          Mapuche   1502     2   1    0    1   305
## 159                         Zanzibar   1502   205  41   41  123   877
## 160                        Franconia   1500     3   2    0    1   649
## 161                     Matabeleland   1498     8   3    2    3   326
## 162                          Estonia   1498   534 132  118  284     1
## 163                          Sealand   1498    12   4    5    3  1438
## 164                            Benin   1497   308  78   75  155     0
## 165                    South Ossetia   1495    16   5    3    8   568
## 166                         Saugeais   1495     1   0    1    0  1635
## 167                         Botswana   1495   319  88   89  142     0
## 168                         Shetland   1495    55  21    7   27   157
## 169                             Togo   1494   435 137  110  188     1
## 170                        Palestine   1493   229  66   63  100     0
## 171                         Délvidék   1492     2   1    0    1  1095
## 172                           Uganda   1491   670 278  180  212     0
## 173          United Koreans in Japan   1490    12   3    6    3   819
## 174                         Tanzania   1489   580 160  167  253     0
## 175                   Western Sahara   1488     5   2    0    3  1858
## 176                       West Papua   1488     1   0    1    0   264
## 177                           Madrid   1487     1   0    0    1  1652
## 178                       Kyrgyzstan   1485   181  56   29   96     0
## 179                            Burma   1485     7   2    2    3 12876
## 180                  Western Armenia   1485    16   5    4    7   665
## 181                             Gozo   1484    11   4    0    7   157
## 182                           Rwanda   1482   268  84   73  111     0
## 183                            Kenya   1482   690 263  169  258     1
## 184                       Luhansk PR   1481     6   2    1    3   568
## 185                     Székely Land   1481    27   9    3   15   167
## 186                       Mauritania   1481   255  49   64  142     0
## 187                            Malta   1480   444  61   75  308     2
## 188                          Cilento   1478     1   0    0    1  1948
## 189                        Greenland   1476    76  25   10   41   157
## 190                       Guadeloupe   1475   264 111   47  106     0
## 191                           Ryūkyū   1474     1   0    0    1  1045
## 192                           Tahiti   1473   239 129   31   79     4
## 193                    Yoruba Nation   1473     2   0    1    1   328
## 194                       Somaliland   1473     6   2    1    3   682
## 195                          Seborga   1473     1   0    0    1  1438
## 196                           Kuwait   1468   665 282  171  212     0
## 197                           Gambia   1468   253  68   72  113     1
## 198            Republic of St. Pauli   1467     4   1    1    2  3111
## 199                      El Salvador   1465   596 195  133  268     2
## 200                    North Vietnam   1464    24   7    3   14 10962
## 201                             Niue   1464     2   0    0    2  8308
## 202                    Åland Islands   1462    51  21    8   22   157
## 203                      South Yemen   1461     3   0    0    3  8452
## 204                            Hmong   1458     3   1    0    2   150
## 205                          Kabylia   1457     6   1    2    3   819
## 206                         Zimbabwe   1457   477 187  132  158     1
## 207                    Guinea-Bissau   1456   178  51   41   86     0
## 208                       Tajikistan   1456   188  70   41   77     9
## 209                           Malaya   1455     2   0    0    2 12875
## 210                    Romani people   1454     7   2    0    5  1144
## 211                         Chechnya   1454     3   0    1    2  3170
## 212                       Madagascar   1452   308 113   72  123     1
## 213                           Aymara   1452     2   0    0    2   304
## 214                             Cuba   1452   384 135   88  161     1
## 215                          Curaçao   1449   367 135   95  137     1
## 216                            Sápmi   1447    29  12    2   15   155
## 217               Dominican Republic   1446   143  57   21   65     0
## 218                         Provence   1443    19   6    1   12  1691
## 219                          Burundi   1442   207  63   50   94     2
## 220                    Western Isles   1442    32  13    3   16   157
## 221                           Monaco   1441    24   8    6   10   986
## 222                         Saarland   1437     9   1    2    6 13108
## 223                           Cyprus   1435   410  77   68  265     0
## 224                           Ticino   1432     2   0    0    2   151
## 225                        Manchukuo   1431     3   0    0    3 14213
## 226                     Sierra Leone   1430   290  87   75  128     0
## 227                         Găgăuzia   1428     3   0    1    2  3012
## 228                            Palau   1427     2   0    0    2  4945
## 229                          Mayotte   1422    38  11   11   16   148
## 230                           Malawi   1419   631 215  178  238     0
## 231                           Latvia   1417   446 127  106  213     2
## 232                  Solomon Islands   1416   205  88   35   82     5
## 233                     Two Sicilies   1416     6   1    0    5   167
## 234                          Vietnam   1415   282 115   58  109     3
## 235                          Namibia   1414   267  67   76  124     1
## 236                        Lithuania   1413   417 110   79  228     0
## 237                          Lebanon   1410   321  87   88  146     9
## 238         Central African Republic   1407   128  27   27   74     0
## 239                          Vanuatu   1406   205  66   27  112     3
## 240                             Sark   1406     4   0    0    4  3754
## 241                           Barawa   1403    12   3    0    9   680
## 242                           Raetia   1398    26   6    5   15   151
## 243                          Gotland   1397    30  11    4   15   952
## 244                    French Guiana   1393   177  54   38   85     1
## 245                 Vietnam Republic   1387   195  82   37   76 10046
## 246                        Ambazonia   1387     6   0    1    5  2910
## 247                     Vatican City   1386     7   0    3    4   686
## 248                            Congo   1385   403 135   98  170     0
## 249                        Yemen DPR   1381    25   5    3   17  6943
## 250                Western Australia   1379    32  11    3   18  8882
## 251                         Ethiopia   1374   399 140   92  167     0
## 252                           Guyana   1372   300  94   61  145     0
## 253                       East Timor   1372     4   0    0    4   392
## 254                    Western Samoa   1369     6   0    0    6  8720
## 255                       Micronesia   1364     7   1    0    6  3750
## 256                    Faroe Islands   1363   272  49   36  187     2
## 257                 Papua New Guinea   1359   147  48   26   73     5
## 258                           Orkney   1359    24   6    1   17   157
## 259                        Singapore   1357   676 211  137  328    46
## 260                            India   1357   522 189  116  217     3
## 261                           Darfur   1356     7   0    0    7  1483
## 262                          Lesotho   1351   285  51   91  143     0
## 263                 Saint Barthélemy   1350    10   4    1    5   208
## 264                     Saare County   1347    35   5    5   25   952
## 265                          Bermuda   1347   184  64   32   88     0
## 266                            Hitra   1339    19   4    1   14   654
## 267        Saint Pierre and Miquelon   1339     7   0    0    7  1789
## 268                      Saint Lucia   1338   223  79   33  111     1
## 269                   Chagos Islands   1335    16   3    2   11   562
## 270                     Saint Helena   1333     8   0    0    8   157
## 271                     Turkmenistan   1333   169  59   32   78    46
## 272                      Puerto Rico   1331   152  37   24   91     1
## 273                          Liberia   1322   289  74   67  148     1
## 274                            Niger   1319   244  54   58  132     0
## 275 Saint Vincent and the Grenadines   1310   220  79   48   93     2
## 276                         Eswatini   1305   266  55   79  132     1
## 277            Saint Kitts and Nevis   1303   213  85   41   87     0
## 278                           Belize   1302   111  28   19   64     0
## 279        Wallis Islands and Futuna   1300    24   5    0   19  5674
## 280                         Kiribati   1299    11   0    1   10  2004
## 281                      Afghanistan   1296   137  35   32   70    46
## 282                             Chad   1290   126  26   30   70     0
## 283                        Hong Kong   1288   429 132   92  205     0
## 284                            Samoa   1277    63  22    4   37     3
## 285                      Philippines   1269   331  85   48  198     9
## 286                       Montserrat   1267    62  16    7   39     2
## 287                        Gibraltar   1262   145  37   18   90     2
## 288                            Tibet   1262    16   0    2   14   151
## 289                            Yemen   1262   255  48   51  156    46
## 290                          Grenada   1258   247  80   55  112     1
## 291                        Mauritius   1254   318  91   70  157    11
## 292                      South Sudan   1251    69  11   13   45     0
## 293                     Sint Maarten   1251    54  17    8   29     1
## 294                            Frøya   1249    33   7    2   24   157
## 295                     Saint Martin   1241    60  21    5   34     1
## 296                           Tuvalu   1235    39   8    4   27   111
## 297                          Andorra   1231   212  13   27  172     2
## 298                          Bonaire   1227    36  13    6   17     2
## 299                 Falkland Islands   1226    33   6    1   26   157
## 300                         Dominica   1216   205  51   42  112     0
## 301                         Barbados   1205   292  93   64  135     0
## 302                          Eritrea   1191    71  11   16   44   599
## 303                          Myanmar   1179   492 204   86  202     2
## 304                           Taiwan   1171   226  62   29  135     4
## 305                     Cook Islands   1169    53  11    4   38    11
## 306                            Aruba   1168   142  28   29   85     1
## 307            São Tomé and Príncipe   1165    65   8   10   47    48
## 308              Antigua and Barbuda   1164   225  71   41  113     0
## 309                   Cayman Islands   1160   110  23   20   67     0
## 310                    Liechtenstein   1149   243  18   32  193     2
## 311                            Nepal   1146   257  61   44  152    46
## 312                       Bangladesh   1144   293  76   62  155     9
## 313                         Djibouti   1144   105   7   10   88    48
## 314                         Maldives   1127   220  61   37  122   126
## 315                         Alderney   1118   135   5    2  128   337
## 316                          Bahamas   1098    61  14   10   37     0
## 317                            Tonga   1095    68  16    6   46     8
## 318                         Cambodia   1083   285  62   39  184     0
## 319         Turks and Caicos Islands   1058    50  11    5   34     0
## 320                   American Samoa   1051    53   4    2   47    11
## 321                         Mongolia   1049    99  25    9   65     7
## 322                       Seychelles   1043   170  26   30  114    46
## 323                           Brunei   1042   128  21   10   97     7
## 324                         Pakistan   1020   239  50   41  148    46
## 325                          Somalia   1020   116  10   13   93    47
## 326         Northern Mariana Islands   1018    30   4    3   23    60
## 327                       San Marino    988   209   2    9  198     2
## 328           British Virgin Islands    981   113  18   20   75     3
## 329                        Sri Lanka    980   237  44   46  147     2
## 330                             Guam    975   115  23   10   82    60
## 331                             Laos    974   212  41   31  140   126
## 332     United States Virgin Islands    960    74   8   11   55     3
## 333                         Anguilla    959    83   5    9   69     3
## 334                           Bhutan    940   103  11    6   86     9
## 335                            Macau    916   141  21   16  104     7
## 336                      Timor-Leste    898    70   7    4   59     7

Exercise 2, Part E: Filter Teams with More than 40 Games

To focus on teams with significant match experience, filter for teams that have played more than 40 games. Extract ratings from the Elo calculation and filter by game count.

ratings_filtered <- elo_ratings_international[["ratings"]] %>%
  filter(Games > 40)

# View the filtered ratings
view(ratings_filtered)