DATA 607 Project 1: Approach

Author

Yalda Azamee

Published

November 28, 2026

Introduction

In this project, I am given a text file of chess tournament results (tournamentinfo.txt). The file has some structure, but it is not a table that R can read directly. My goal is to create a CSV file with one row per player and five columns: Player’s Name, Player’s State, Total Number of Points, Player’s Pre-Rating, and Average Pre-Chess Rating of Opponents. For example, the first row should be Gary Hua, ON, 6.0, 1794, 1605.

Planned Approach

Understanding the file

The file has 64 players. Each player takes up two lines, and the players are separated by lines of dashes (-----). The columns within a line are separated by the | character.

  • First line: pair number, player name, total points, and the result of each of the 7 rounds (for example W 39 means a win against player 39).
  • Second line: state, USCF ID, and the pre- and post-tournament ratings (for example R: 1794 ->1817).

Steps

  1. Read the data. I will upload tournamentinfo.txt to my GitHub repository and read it from its raw GitHub URL with readr::read_lines(), so the code runs on any computer.
  2. Remove lines that are not player data. I will drop the dashed separator lines and the two header lines.
  3. Separate the two lines of each player. Odd lines will be the first line and even lines the second line, so row i of each refers to the same player.
  4. Split each line on |. This gives one column per field.
  5. Extract the player fields with stringr: pair number, name, state, total points, and pre-rating.
  6. Extract the opponents. From the 7 round columns, I will keep the opponent pair numbers for games that were played.
  7. Calculate the average opponent pre-rating. Using the pair number, I will look up each opponent’s pre-rating, then take the mean and round it to a whole number.
  8. Check the result against the example in the instructions (Gary Hua should be 1605).
  9. Write the CSV with readr::write_csv().

Anticipated Data Challenges

  • Two lines per player. The information for one player is split across two lines, so the lines must be paired correctly before extracting anything.
  • Provisional ratings. Some pre-ratings include extra characters, such as R: 1641P17. I will keep only the digits right after R:.
  • Rounds without a game. Some rounds are not wins, losses, or draws: H (half-point bye), U (unplayed), B (full-point bye), and X (forfeit win). These have no real opponent. I plan to count only W, L, and D rounds, so the average is divided by the number of games actually played, as described in the instructions.
  • Looking up opponents. Each opponent appears only as a pair number, so I need to match it back to that player’s pre-rating.
  • Extra spaces and formatting. Names and values have padding spaces that must be trimmed. Points should keep one decimal place (6.0).
  • Reproducibility. The data must be read from a URL, not a local file path.

AI Use

Used AI to understand the assignment.