The goal of this project is to perform manipulations from a given text file and create a CSV file that has a players name, state, total points, initial rating, and the average rating of their opponents. To start I will be pulling the text file and read it while cleaning the dataframe
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.2.1 ✔ readr 2.2.0
✔ forcats 1.0.1 ✔ stringr 1.6.0
✔ ggplot2 4.0.3 ✔ tibble 3.3.1
✔ lubridate 1.9.5 ✔ tidyr 1.3.2
✔ purrr 1.2.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Warning in readLines("ELO.txt"): incomplete final line found on 'ELO.txt'
elo <- elo |>slice(-1) |>select(-X)
Splitting the data
at this point I have two rows dedicated to information for each player. I will break these rows up into two different dataframes. In addition, I need the starting elo of each player added to one of the dataframes. To achieve this, I used string manipulation to split the string containing the player’s id number, starting elo, and ending elo. There was also a provisional rating that we are choosing to ignore that had to be removed from some lines.
Now that we have moved onto the odd rows, we will need to remove the win/lose/draw indicators in the round elements. Once that is achieved with more string manipulations we can go on to replace the indexes the elements represent with the starting elo of each of the player’s opponents. once that is in place we are able to find the rounded mean elo of their opponents and add a column to our odd row dataframe.
Now that we have successfully broken down the data we are able to create a new dataframe using information from both dataframes we have created. This will ultimately produce a dataset that has all the relevant player information for each player
The following object is masked from 'package:purrr':
discard
The following object is masked from 'package:readr':
col_factor
Findings and Conclusion
Looking at the data gathered, we can see that the average player rating is 1378.625. The average difference between the mean player elo and the elo of any given player is -0.125. This may seem like a fair enough differential, it does not take into account the high variance in the ratings. When taking this into account the percent chance for the average player to beat the worst player is 99.7% and the chance for the average player to beat the best player is 8.4% the skill discrepancy is very high in this dataset and it could offer a better experience to break this into two different tournaments. The loss of elo may hurt lower rated players less, but it would not offer them the same improvement opportunities as facing similarly skilled opponents.