Prepare some libraries and set the working directory.

library(stringr)
## Warning: package 'stringr' was built under R version 3.2.5
library(plyr)
## Warning: package 'plyr' was built under R version 3.2.5
working.dir <- "G:/OneDrive/Learning/_CUNY_SPS_MSDS/2018_Spring/DATA 607/Projects/Project 1"
setwd(working.dir)

Get the data in a table

# Import data from text file.
chess.sourcefile <- paste0(working.dir, "/tournamentinfo.txt")

Produce data table header. Tried scan(), but changed to read.table delimited by “|”, and then concatenated the two rows horizontally using cbind.

header.rt <- read.table(chess.sourcefile, sep = "|", fill = T, nrows = 3, stringsAsFactors = F)
# Grab rows 2 and 3.
header1 <- header.rt[2,] 
header2 <- header.rt[3,]
header.comb <- cbind(header1, header2)
# Clean up residual objects.
header.rt <- NULL
header1 <- NULL
header2 <- NULL

Cleaned up the header using str_trim, removing residual whitespace on both ends of all strings.

header.clean <- str_trim(header.comb)
# Clean up residual objects.
header.comb <- NULL

Renamed row values, which will serve as column headers when combined. Originally tried this at later a step, but it proved confusing when organizing columnar vectors and operations thereupon.

header.clean[1:3] <- c("Pairing Number", "Player\'s Name", "Tourney Points")
header.clean[4:10] <- c("Rnd1", "Rnd2", "Rnd3", "Rnd4", "Rnd5", "Rnd6", "Rnd7")
header.clean[12] <- c("Player's State")
header.clean[14:21] <- c("N:Value", "Rnd1 Outcome", "Rnd2 Outcome", "Rnd3 Outcome", "Rnd4 Outcome", "Rnd5 Outcome", "Rnd6 Outcome", "Rnd7 Outcome")

Extract table body from text file using read-table delimited by “|”. Just like for the header.

chess.source <- read.table(chess.sourcefile, sep = "|", fill = T, skip = 4, header = F, stringsAsFactors = F)

Produce one row per competitor. Subset the table, which as read is a blank row followed by two separate rows which pertain to each competitor. Remove the blank rows, and concatenate the remaining rows horizontally using cbind.

# Get count of rows for subsetting.
source.rows <- nrow(chess.source)
# Remove blank rows and concatenate the remaining by competitor.
seq1 <- seq(1, as.integer(source.rows), 3)
seq2 <- seq(2, as.integer(source.rows), 3)
row1 <- chess.source[seq1,]
row2 <- chess.source[seq2,]
chess.comb <- cbind(row1, row2)
# Clean up residual objects.
seq1 <- NULL
seq2 <- NULL
row1 <- NULL
row2 <- NULL

Append column headers to the table body. Rbind the header atop the body, set the resulting first row as colnames, then eliminate the first row and wipe the temp table. Attempted a more direct approach setting header.clean as colnames for chess.master, but troubleshooting proved fruitless.

chess.master <- rbind(header.clean, chess.comb)
# Create a temp file to prep the header names and read them in to the master table.
chess.master.temp <- chess.master
chess.master.temp[] <- lapply(chess.master, as.character)
colnames(chess.master) <- chess.master.temp[1,]
# Eliminate the first row and temp table.
chess.master <- chess.master[-1,]
chess.master.temp <- NULL

Clean up the table. Assign data types and trim leading / trailing white space within column values. NB: the outcome refers to how the competitor won, lost, or drew (i.e. received a bye, won the match, etc.) - this is treated separately from whether they won, lost, or drew, which is reflected in a column to be created.

# Would like to learn how to employ a for-loop here - there's no way this code is efficient.
chess.master$`Pairing Number`<- as.integer(str_trim(chess.master$`Pairing Number`))
chess.master$`Player's Name` <- str_trim(chess.master$`Player's Name`)
chess.master$`Tourney Points` <- as.numeric(chess.master$`Tourney Points`)
chess.master$`Player's State` <- str_trim(chess.master$`Player's State`)
chess.master$`Rnd1 Outcome` <- str_trim(chess.master$`Rnd1 Outcome`)
chess.master$`Rnd2 Outcome` <- str_trim(chess.master$`Rnd2 Outcome`)
chess.master$`Rnd3 Outcome` <- str_trim(chess.master$`Rnd3 Outcome`)
chess.master$`Rnd4 Outcome` <- str_trim(chess.master$`Rnd4 Outcome`)
chess.master$`Rnd5 Outcome` <- str_trim(chess.master$`Rnd5 Outcome`)
chess.master$`Rnd6 Outcome` <- str_trim(chess.master$`Rnd6 Outcome`)
chess.master$`Rnd7 Outcome` <- str_trim(chess.master$`Rnd7 Outcome`)

Column 13 contains three data points: the player’s lifetime points, their pre-tourney rating, and their post-tourney rating. Use regular expressions to parse these values and read them into three separate, labelled columns.

# Extract column 13 from chess.master.
chess.ptrt.orig <- chess.master[,13]
# Extract data points, ensuring that every competitor receives a value for each (i.e. the new vectors line up cleanly with chess.master table row order).
chess.points <- unlist(str_extract_all(chess.ptrt.orig, "(?<=\\s)[0-9]+(?=\\s/)"))
chess.prertg <- unlist(str_extract_all(chess.ptrt.orig, "(?<=:\\s|\\s{2})[0-9]{3,4}"))
chess.pstrtg <- unlist(str_extract_all(chess.ptrt.orig, "(?<=>|>\\s)[0-9]{3,4}"))
# Append the columnar vectors back to the table as new separate columns.
chess.master <- cbind(chess.master, 
                      chess.points, 
                      chess.prertg, 
                      chess.pstrtg)
# Label the new columns.
colnames(chess.master)[23] <- "Lifetime Points"
colnames(chess.master)[24] <- "Player\'s Pre-Tourney Rating"
colnames(chess.master)[25] <- "Player\'s Post-Tourney Rating"

Columns 4 through 10 contain several data points: the player’s opponent in a given numbered round and the result of that round. Use regular expressions to parse these values and read them into two separate, labelled columns for each round. NB: the result of the round indicates whether the competitor won, lost, of drew; the outcome refers to how the competitor won, lost, or drew (i.e. received a bye, won the match, etc.).

# Would like to learn how to employ a for-loop here - there's no way this code is efficient.
# Extract columns 4 through 10 from chess.master. 
chess.rnd.orig <- chess.master[4:10]
# Extract data points, ensuring that every competitor receives a value for each (i.e. the new vectors line up cleanly with chess.master table row order).
chess.rnd1.opponent <- unlist(str_extract_all(chess.rnd.orig[,1], "\\d+|\\s$"))
chess.rnd1.result <- unlist(str_extract_all(chess.rnd.orig[,1], "^[[:upper:]]"))
chess.rnd2.opponent <- unlist(str_extract_all(chess.rnd.orig[,2], "\\d+|\\s$"))
chess.rnd2.result <- unlist(str_extract_all(chess.rnd.orig[,2], "^[[:upper:]]"))
chess.rnd3.opponent <- unlist(str_extract_all(chess.rnd.orig[,3], "\\d+|\\s$"))
chess.rnd3.result <- unlist(str_extract_all(chess.rnd.orig[,3], "^[[:upper:]]"))
chess.rnd4.opponent <- unlist(str_extract_all(chess.rnd.orig[,4], "\\d+|\\s$"))
chess.rnd4.result <- unlist(str_extract_all(chess.rnd.orig[,4], "^[[:upper:]]"))
chess.rnd5.opponent <- unlist(str_extract_all(chess.rnd.orig[,5], "\\d+|\\s$"))
chess.rnd5.result <- unlist(str_extract_all(chess.rnd.orig[,5], "^[[:upper:]]"))
chess.rnd6.opponent <- unlist(str_extract_all(chess.rnd.orig[,6], "\\d+|\\s$"))
chess.rnd6.result <- unlist(str_extract_all(chess.rnd.orig[,6], "^[[:upper:]]"))
chess.rnd7.opponent <- unlist(str_extract_all(chess.rnd.orig[,7], "\\d+|\\s$"))
chess.rnd7.result <- unlist(str_extract_all(chess.rnd.orig[,7], "^[[:upper:]]"))
# Append the columnar vectors back to the table as new separate columns: seven identifying the opponent in each round, seven identifying whether the result of the round (win, lose, draw)
chess.master <- cbind(chess.master, 
                      chess.rnd1.result, 
                      chess.rnd2.result, 
                      chess.rnd3.result, 
                      chess.rnd4.result, 
                      chess.rnd5.result, 
                      chess.rnd6.result, 
                      chess.rnd7.result, 
                      chess.rnd1.opponent, 
                      chess.rnd2.opponent, 
                      chess.rnd3.opponent, 
                      chess.rnd4.opponent, 
                      chess.rnd5.opponent, 
                      chess.rnd6.opponent, 
                      chess.rnd7.opponent)
# Label the new columns.
colnames(chess.master)[26:32] <- c("Rnd1 Result",
                                   "Rnd2 Result",
                                   "Rnd3 Result",
                                   "Rnd4 Result",
                                   "Rnd5 Result",
                                   "Rnd6 Result",
                                   "Rnd7 Result")
colnames(chess.master)[33:39] <- c("Rnd1 Opponent",
                                   "Rnd2 Opponent",
                                   "Rnd3 Opponent",
                                   "Rnd4 Opponent",
                                   "Rnd5 Opponent",
                                   "Rnd6 Opponent",
                                   "Rnd7 Opponent")

In order to calculate the average pre-tourney raiting for opponents for each competitor, we’ll need to determine in how many rounds competitors competed, and the ranking of each of those opponents. Vectorizing these rows proved a challenge. I attempted the apply class of functions to most underwhelming effect and eventually discontinued that approach to avoid impending self-harm. Fell back on trying to call the opponent rating corresponding to opponent pairing number for each round but couldn’t troubleshoot the syntax satisfactorily.

# The aim is to extract opponents for each round and then look up their ratings.  I could not get plyr or for-loops to play nice, and fell back on the approach below, which still did not work.  The R_0 vector isn't getting correctly called for the R_R vector below, and the resulting player ratings are based on opponent pairing numbers not pre-tourney ratings.  Sigh...
# Would like to learn how to employ a for-loop here - there's no way this code is efficient.
R1O <- (chess.master$`Rnd1 Opponent`)
R1R <- as.integer(chess.master$`Player's Pre-Tourney Rating`[R1O])
R2O <- (chess.master$`Rnd2 Opponent`)
R2R <- as.integer(chess.master$`Player's Pre-Tourney Rating`[R2O])
R3O <- (chess.master$`Rnd3 Opponent`)
R3R <- as.integer(chess.master$`Player's Pre-Tourney Rating`[R3O])
R4O <- (chess.master$`Rnd4 Opponent`)
R4R <- as.integer(chess.master$`Player's Pre-Tourney Rating`[R4O])
R5O <- (chess.master$`Rnd5 Opponent`)
R5R <- as.integer(chess.master$`Player's Pre-Tourney Rating`[R5O])
R6O <- (chess.master$`Rnd6 Opponent`)
R6R <- as.integer(chess.master$`Player's Pre-Tourney Rating`[R6O])
R7O <- (chess.master$`Rnd7 Opponent`)
R7R <- as.integer(chess.master$`Player's Pre-Tourney Rating`[R7O])
# Collect the opponents ratings and sum them across rounds (i.e. by rows).  This will serve as the numerator when calculating average opponent rating.
opponents.ratings <- cbind(R1R, R2R, R3R, R4R, R5R, R6R, R7R)
opponents.ratings.cum <- apply(opponents.ratings, MARGIN = 1, FUN = sum)
# Collect the result of each round - win (W), lose (L), or draw (D).  
matches.played <- cbind(as.character(chess.master$`Rnd1 Result`), 
                       as.character(chess.master$`Rnd2 Result`),
                       as.character(chess.master$`Rnd3 Result`),
                       as.character(chess.master$`Rnd4 Result`),
                       as.character(chess.master$`Rnd5 Result`),
                       as.character(chess.master$`Rnd6 Result`),
                       as.character(chess.master$`Rnd7 Result`))
# Calculate the total number of games played (i.e. sum of wins, losses, and draws).  This will serve as the denominator when calculating the average opponent rating.
matches.played.wld <- rowSums(matches.played == "W") + rowSums(matches.played == "L") + rowSums(matches.played == "D")
# Calculate the average opponent rating.
opponents.rating.avg <- opponents.ratings.cum / matches.played.wld
# Append the columnar vector back to the table a new separate column.
chess.master <- cbind(chess.master, opponents.rating.avg)
# Label the new column - would that it were correctly computed...
colnames(chess.master)[40] <- "Avg Pre-Tourney Opponent Rating"

Reorganize table for easier access, pruning surplus columns.

chess.final.cols <- c("Pairing Number", "Player\'s Name", "Lifetime Points", "Player\'s State", "N:Value", "Tourney Points", "Avg Pre-Tourney Opponent Rating", "Player\'s Pre-Tourney Rating", "Player\'s Post-Tourney Rating", "Rnd1 Opponent", "Rnd1 Outcome", "Rnd1 Result", "Rnd2 Opponent", "Rnd2 Outcome", "Rnd2 Result", "Rnd3 Opponent", "Rnd3 Outcome", "Rnd3 Result", "Rnd4 Opponent", "Rnd4 Outcome", "Rnd4 Result", "Rnd5 Opponent", "Rnd5 Outcome", "Rnd5 Result", "Rnd6 Opponent", "Rnd6 Outcome", "Rnd6 Result", "Rnd7 Opponent", "Rnd7 Outcome", "Rnd7 Result")
chess.final <- chess.master[chess.final.cols]
chess.final
##     Pairing Number              Player's Name Lifetime Points
## 11               1                   GARY HUA        15445895
## 4                2            DAKSHESH DARURI        14598900
## 7                3               ADITYA BAJAJ        14959604
## 10               4        PATRICK H SCHILLING        12616049
## 13               5                 HANSHI ZUO        14601533
## 16               6                HANSEN SONG        15055204
## 19               7          GARY DEE SWATHELL        11146376
## 22               8           EZEKIEL HOUGHTON        15142253
## 25               9                STEFANO LEE        14954524
## 28              10                  ANVIT RAO        14150362
## 31              11   CAMERON WILLIAM MC LEMAN        12581589
## 34              12             KENNETH J TACK        12681257
## 37              13          TORRANCE HENRY JR        15082995
## 40              14               BRADLEY SHAW        10131499
## 43              15     ZACHARY JAMES HOUGHTON        15619130
## 46              16               MIKE NIKITIN        10295068
## 49              17         RONALD GRZEGORCZYK        10297702
## 52              18              DAVID SUNDEEN        11342094
## 55              19               DIPANKAR ROY        14862333
## 58              20                JASON ZHENG        14529060
## 61              21              DINH DANG BUI        15495066
## 64              22           EUGENE L MCCLURE        12405534
## 67              23                   ALAN BUI        15030142
## 70              24          MICHAEL R ALDRICH        13469010
## 73              25           LOREN SCHWIEBERT        12486656
## 76              26                    MAX ZHU        15131520
## 79              27             GAURAV GIDWANI        14476567
## 82              28 SOFIA ADINA STANESCU-BELLU        14882954
## 85              29           CHIEDOZIE OKORIE        15323285
## 88              30         GEORGE AVERY JONES        12577178
## 91              31               RISHI SHETTY        15131618
## 94              32      JOSHUA PHILIP MATHEWS        14073750
## 97              33                    JADE GE        14691842
## 100             34     MICHAEL JEFFERY THOMAS        15051807
## 103             35           JOSHUA DAVID LEE        14601397
## 106             36              SIDDHARTH JHA        14773163
## 109             37       AMIYATOSH PWNANANDAM        15489571
## 112             38                  BRIAN LIU        15108523
## 115             39              JOEL R HENDON        12923035
## 118             40               FOREST ZHANG        14892710
## 121             41        KYLE WILLIAM MURPHY        15761443
## 124             42                   JARED GE        14462326
## 127             43          ROBERT GLEN VASEY        14101068
## 130             44         JUSTIN D SCHILLING        15323504
## 133             45                  DEREK YAN        15372807
## 136             46   JACOB ALEXANDER LAVALLEY        15490981
## 139             47                ERIC WRIGHT        12533115
## 142             48               DANIEL KHAIN        14369165
## 145             49           MICHAEL J MARTIN        12531685
## 148             50                 SHIVAM JHA        14773178
## 151             51             TEJAS AYYAGARI        15205474
## 154             52                  ETHAN GUO        14918803
## 157             53              JOSE C YBARRA        12578849
## 160             54                LARRY HODGE        12836773
## 163             55                  ALEX KONG        15412571
## 166             56               MARISA RICCI        14679887
## 169             57                 MICHAEL LU        15113330
## 172             58               VIRAJ MOHILE        14700365
## 175             59          SEAN M MC CORMICK        12841036
## 178             60                 JULIA SHEN        14579262
## 181             61              JEZZEL FARKAS        15771592
## 184             62              ASHWIN BALAJI        15219542
## 187             63       THOMAS JOSEPH HOSMER        15057092
## 190             64                     BEN LI        15006561
##     Player's State N:Value Tourney Points Avg Pre-Tourney Opponent Rating
## 11              ON   N:2              6.0                        27.14286
## 4               MI   N:2              6.0                        24.42857
## 7               MI   N:2              6.0                        47.57143
## 10              MI   N:2              5.5                        42.00000
## 13              MI   N:2              5.5                        38.57143
## 16              OH   N:3              5.0                        37.00000
## 19              MI   N:3              5.0                        38.85714
## 22              MI   N:3              5.0                        36.71429
## 25              ON   N:2              5.0                        35.71429
## 28              MI   N:3              5.0                        35.71429
## 31              MI   N:3              4.5                        35.57143
## 34              MI   N:3              4.5                        44.83333
## 37              MI   N:3              4.5                        35.57143
## 40              MI   N:3              4.5                        29.14286
## 43              MI   N:3              4.5                        30.57143
## 46              MI   N:3              4.0                        58.20000
## 49              MI   N:3              4.0                        35.71429
## 52              MI   N:3              4.0                        30.14286
## 55              MI   N:3              4.0                        26.71429
## 58              MI   N:4              4.0                        35.71429
## 61              ON   N:3              4.0                        21.00000
## 64              MI   N:4              4.0                        44.83333
## 67              ON                    4.0                        28.42857
## 70              MI   N:4              4.0                        28.00000
## 73              MI   N:4              3.5                        30.28571
## 76              ON   N:4              3.5                        28.42857
## 79              MI   N:4              3.5                        48.00000
## 82              MI   N:3              3.5                        39.57143
## 85              MI   N:4              3.5                        30.66667
## 88              ON                    3.5                        23.14286
## 91              MI                    3.5                        31.85714
## 94              ON   N:4              3.5                        33.57143
## 97              MI                    3.5                        30.85714
## 100             MI                    3.5                        26.71429
## 103             MI                    3.5                        14.28571
## 106             MI   N:4              3.5                        46.83333
## 109             MI                    3.5                        58.40000
## 112             MI   N:4              3.0                        56.00000
## 115             MI   N:4              3.0                        24.71429
## 118             MI                    3.0                        26.00000
## 121             MI                    3.0                        89.75000
## 124             MI                    3.0                        16.42857
## 127             MI                    3.0                        36.57143
## 130             MI                    3.0                        41.66667
## 133             MI                    3.0                        19.14286
## 136             MI                    3.0                        32.85714
## 139             MI                    2.5                        52.14286
## 142             MI                    2.5                        52.40000
## 145             MI                    2.5                        55.20000
## 148             MI                    2.5                        38.83333
## 151             MI                    2.5                        35.42857
## 154             MI   N:4              2.5                        39.57143
## 157             MI                    2.0                       115.00000
## 160             MI                    2.0                        44.50000
## 163             MI                    2.0                        37.50000
## 166             MI                    2.0                        55.80000
## 169             MI                    2.0                        47.83333
## 172             MI                    2.0                        50.83333
## 175             MI                    2.0                        35.83333
## 178             MI                    1.5                        55.80000
## 181             ON                    1.5                        30.00000
## 184             MI                    1.0                       356.00000
## 187             MI                    1.0                        48.80000
## 190             MI                    1.0                        37.14286
##     Player's Pre-Tourney Rating Player's Post-Tourney Rating Rnd1 Opponent
## 11                         1794                         1817            39
## 4                          1553                         1663            63
## 7                          1384                         1640             8
## 10                         1716                         1744            23
## 13                         1655                         1690            45
## 16                         1686                         1687            34
## 19                         1649                         1673            57
## 22                         1641                         1657             3
## 25                         1411                         1564            25
## 28                         1365                         1544            16
## 31                         1712                         1696            38
## 34                         1663                         1670            42
## 37                         1666                         1662            36
## 40                         1610                         1618            54
## 43                         1220                         1416            19
## 46                         1604                         1613            10
## 49                         1629                         1610            48
## 52                         1600                         1600            47
## 55                         1564                         1570            15
## 58                         1595                         1569            40
## 61                         1563                         1562            43
## 64                         1555                         1529            64
## 67                         1363                         1371             4
## 70                         1229                         1300            28
## 73                         1745                         1681             9
## 76                         1579                         1564            49
## 79                         1552                         1539            51
## 82                         1507                         1513            24
## 85                         1602                         1508            50
## 88                         1522                         1444            52
## 91                         1494                         1444            58
## 94                         1441                         1433            61
## 97                         1449                         1421            60
## 100                        1399                         1400             6
## 103                        1438                         1392            46
## 106                        1355                         1367            13
## 109                         980                         1077              
## 112                        1423                         1439            11
## 115                        1436                         1413             1
## 118                        1348                         1346            20
## 121                        1403                         1341            59
## 124                        1332                         1256            12
## 127                        1283                         1244            21
## 130                        1199                         1199              
## 133                        1242                         1191             5
## 136                         377                         1076            35
## 139                        1362                         1341            18
## 142                        1382                         1335            17
## 145                        1291                         1259            26
## 148                        1056                         1111            29
## 151                        1011                         1097            27
## 154                         935                         1092            30
## 157                        1393                         1359              
## 160                        1270                         1200            14
## 163                        1186                         1163            62
## 166                        1153                         1140              
## 169                        1092                         1079             7
## 172                         917                          941            31
## 175                         853                          878            41
## 178                         967                          984            33
## 181                         955                          979            32
## 184                        1530                         1535            55
## 187                        1175                         1125             2
## 190                        1163                         1112            22
##     Rnd1 Outcome Rnd1 Result Rnd2 Opponent Rnd2 Outcome Rnd2 Result
## 11             W           W            21            B           W
## 4              B           W            58            W           W
## 7              W           L            61            B           W
## 10             W           W            28            B           D
## 13             B           W            37            W           W
## 16             W           W            29            B           D
## 19             W           W            46            B           W
## 22             B           W            32            W           W
## 25             W           W            18            B           L
## 28             W           D            19            W           L
## 31             B           D            56            W           W
## 34             W           W            33            B           W
## 37             B           W            27            W           W
## 40             W           W            44            B           W
## 43             B           D            16            B           L
## 46             B           D            15            W           W
## 49             W           W            41            B           W
## 52             B           W             9            W           W
## 55             W           D            10            B           W
## 58             W           L            49            B           W
## 61             B           W             1            W           L
## 64             W           W            52            B           D
## 67             B           L            43            W           W
## 70             B           L            47            W           L
## 73             B           L            53            W           W
## 76             B           W            40            W           W
## 79             W           W            13            B           L
## 82             W           W             4            W           D
## 85             B           W             6            W           D
## 88             W           L            64            B           D
## 91             B           L            55            W           D
## 94             W           W             8            B           L
## 97             B           W            12            W           L
## 100            B           L            60            W           W
## 103            W           L            38            W           L
## 106            W           L            57            B           W
## 109                        B             5            B           L
## 112            W           D            35            B           W
## 115            B           L            54            W           W
## 118            B           W            26            B           L
## 121            B           W            17            W           L
## 124            B           L            50            W           L
## 127            W           L            23            B           L
## 130                        B            14            W           L
## 133            W           L            51            B           L
## 136            B           W             7            W           L
## 139            W           L            24            B           W
## 142            B           L            63            W           W
## 145            W           L            20            W           L
## 148            W           L            42            B           W
## 151            B           L            45            W           W
## 154            B           W            22            W           D
## 157                        H            25            B           L
## 160            B           L            39            B           L
## 163            W           L            31            B           D
## 166                        H            11            B           L
## 169            B           L            36            W           L
## 172            W           W             2            B           L
## 175            W           L                                      B
## 178            W           L            34            B           L
## 181            B           L             3            W           L
## 184            B           W                                      U
## 187            W           L            48            B           L
## 190            B           L            30            W           D
##     Rnd3 Opponent Rnd3 Outcome Rnd3 Result Rnd4 Opponent Rnd4 Outcome
## 11             18            W           W            14            B
## 4               4            B           L            17            W
## 7              25            W           W            21            B
## 10              2            W           W            26            B
## 13             12            B           D            13            W
## 16             11            W           L            35            B
## 19             13            W           W            11            B
## 22             14            B           L             9            W
## 25             59            W           W             8            B
## 28             55            B           W            31            B
## 31              6            B           W             7            W
## 34              5            W           D            38            B
## 37              7            B           L             5            B
## 40              8            W           W             1            W
## 43             30            W           W            22            W
## 46                                       H            39            B
## 49             26            W           L             2            B
## 52              1            B           L            32            W
## 55             52            W           W            28            B
## 58             23            W           W            41            B
## 61             47            B           W             3            W
## 64             28            W           L            15            B
## 67             20            B           L            58            W
## 70             43            B           W            25            B
## 73              3            B           L            24            W
## 76             17            B           W             4            W
## 79             46            W           W            37            B
## 82             22            B           W            19            W
## 85             38            B           L            34            W
## 88             15            B           L            55            W
## 91             64            B           W            10            W
## 94             44            W           W            18            B
## 97             50            B           W            36            W
## 100            37            B           L            29            B
## 103            56            B           W             6            W
## 106            51            W           W            33            B
## 109            34            W           W            27            W
## 112            29            W           W            12            W
## 115            40            B           W            16            W
## 118            39            W           L            59            W
## 121            58            B           W            20            W
## 124            57            B           L            60            B
## 127            24            W           L            63            W
## 130            32            B           L            53            B
## 133            60            W           D            56            B
## 136            27            B           L            50            W
## 139            21            W           L            61            B
## 142                                      H            52            B
## 145            63            B           D            64            W
## 148            33            W           L            46            B
## 151            36            B           L            57            W
## 154            19            B           L            48            W
## 157                                      H            44            W
## 160            61            W           L                           
## 163            10            W           L            30            B
## 166            35            W           L            45            W
## 169            42            W           W            51            B
## 172            41            W           L            23            B
## 175             9            B           L            40            B
## 178            45            B           D            42            W
## 181            54            B           W            47            W
## 184                                      U                           
## 187            49            W           D            43            B
## 190            31            W           L            49            B
##     Rnd4 Result Rnd5 Opponent Rnd5 Outcome Rnd5 Result Rnd6 Opponent
## 11            W             7            W           W            12
## 4             W            16            B           W            20
## 7             W            11            W           W            13
## 10            W             5            W           D            19
## 13            D             4            B           D            14
## 16            W            10            B           D            27
## 19            W             1            B           L             9
## 22            L            47            B           W            28
## 25            W            26            W           W             7
## 28            W             6            W           D            25
## 31            L             3            B           L            34
## 34            W                                      H             1
## 37            D            33            W           W             3
## 40            L            27            B           D             5
## 43            L            54            B           W            33
## 46            W             2            W           L            36
## 49            L            23            W           W            22
## 52            W            19            B           L            38
## 55            D            18            W           W             4
## 58            W            28            W           W             2
## 61            L            40            W           W            39
## 64            W                                      H            17
## 67            W            17            B           L            37
## 70            L            60            W           W            44
## 73            W            34            B           D            10
## 76            L             9            B           L            32
## 79            W            14            W           D             6
## 82            D            20            B           L             8
## 85            L            52            W           W            48
## 88            W            31            W           L            61
## 91            L            30            B           W            50
## 94            L            51            W           W            26
## 97            D            13            B           L            15
## 100           W            25            W           D            11
## 103           L            57            B           W            52
## 106           D                                      H            16
## 109           L                                      H            23
## 112           L                                      H            18
## 115           L            44            B           W            21
## 118           W            21            B           L            56
## 121           L                                      X              
## 124           D            61            W           D            64
## 127           W            59            B           W            46
## 130           W            39            W           L            24
## 133           L            63            W           W            55
## 136           L            64            B           W            43
## 139           W             8            W           L            51
## 142           D                                      H            29
## 145           D            58            B           W              
## 148           W                                      H            31
## 151           W            32            B           L            47
## 154           D            29            B           L            35
## 157           L                                      U            57
## 160           B            15            W           L            59
## 163           L                                      B            45
## 166           W                                      H            40
## 169           L            35            W           L            53
## 172           L            49            W           L              
## 175           L            43            W           L            54
## 178           D            24            B           L              
## 181           L            42            B           D            30
## 184           U                                      U              
## 187           L            45            B           L              
## 190           D            46            W           L            42
##     Rnd6 Outcome Rnd6 Result Rnd7 Opponent Rnd7 Outcome Rnd7 Result
## 11             B           D             4            W           D
## 4              W           W             7            B           W
## 7              B           W            12            W           W
## 10             B           W             1            B           D
## 13             W           W            17            B           W
## 16             W           W            21            B           W
## 19             W           W             2            W           L
## 22             W           W            19            W           W
## 25             B           L            20            B           W
## 28             B           W            18            W           W
## 31             W           W            26            B           W
## 34             W           D             3            B           L
## 37             W           L            32            B           W
## 40             B           L            31            W           W
## 43             B           W            38            W           W
## 46             B           W                                      U
## 49             B           W             5            W           L
## 52             W           W            10            B           L
## 55             W           L             8            B           L
## 58             B           L             9            W           L
## 61             B           W             6            W           L
## 64             W           L            40            B           W
## 67             W           W            46            B           W
## 70             W           W            39            B           W
## 73             W           L            47            B           W
## 76             W           D            11            W           L
## 79             B           L                                      U
## 82             B           L            36            W           D
## 85             B           W                                      U
## 88             B           W            50            B           W
## 91             W           W            14            B           L
## 94             B           D            13            W           L
## 97             W           L            51            B           W
## 100            B           L            52            W           W
## 103            B           D            48            W           W
## 106            W           L            28            B           D
## 109            B           L            61            W           W
## 112            B           L            15            B           L
## 115            W           L            24            W           L
## 118            W           W            22            W           L
## 121                        U                                      U
## 124            W           W            56            B           W
## 127            B           L            55            W           W
## 130            B           L            59            W           W
## 133            B           D            58            W           W
## 136            W           W            23            W           L
## 139            B           D            25            W           L
## 142            W           L            35            B           L
## 145                        H                                      U
## 148            B           L            30            W           L
## 151            W           D            33            W           L
## 154            W           D            34            B           L
## 157            W           W                                      U
## 160            B           L            64            W           W
## 163            W           D            43            B           L
## 166            B           L            42            W           L
## 169            B           L                                      B
## 172                        B            45            B           L
## 175            W           W            44            B           L
## 178                        H                                      U
## 181            W           L            37            B           L
## 184                        U                                      U
## 187                        H                                      U
## 190            B           L            54            B           L

Configure the output table.

chess.output.cols <- c("Player\'s Name", "Player\'s State", "Tourney Points", "Player\'s Pre-Tourney Rating", "Avg Pre-Tourney Opponent Rating")
output.table <- chess.final[chess.output.cols]
output.table[5] <- as.integer(output.table$`Avg Pre-Tourney Opponent Rating`)
output.table
##                  Player's Name Player's State Tourney Points
## 11                    GARY HUA             ON            6.0
## 4              DAKSHESH DARURI             MI            6.0
## 7                 ADITYA BAJAJ             MI            6.0
## 10         PATRICK H SCHILLING             MI            5.5
## 13                  HANSHI ZUO             MI            5.5
## 16                 HANSEN SONG             OH            5.0
## 19           GARY DEE SWATHELL             MI            5.0
## 22            EZEKIEL HOUGHTON             MI            5.0
## 25                 STEFANO LEE             ON            5.0
## 28                   ANVIT RAO             MI            5.0
## 31    CAMERON WILLIAM MC LEMAN             MI            4.5
## 34              KENNETH J TACK             MI            4.5
## 37           TORRANCE HENRY JR             MI            4.5
## 40                BRADLEY SHAW             MI            4.5
## 43      ZACHARY JAMES HOUGHTON             MI            4.5
## 46                MIKE NIKITIN             MI            4.0
## 49          RONALD GRZEGORCZYK             MI            4.0
## 52               DAVID SUNDEEN             MI            4.0
## 55                DIPANKAR ROY             MI            4.0
## 58                 JASON ZHENG             MI            4.0
## 61               DINH DANG BUI             ON            4.0
## 64            EUGENE L MCCLURE             MI            4.0
## 67                    ALAN BUI             ON            4.0
## 70           MICHAEL R ALDRICH             MI            4.0
## 73            LOREN SCHWIEBERT             MI            3.5
## 76                     MAX ZHU             ON            3.5
## 79              GAURAV GIDWANI             MI            3.5
## 82  SOFIA ADINA STANESCU-BELLU             MI            3.5
## 85            CHIEDOZIE OKORIE             MI            3.5
## 88          GEORGE AVERY JONES             ON            3.5
## 91                RISHI SHETTY             MI            3.5
## 94       JOSHUA PHILIP MATHEWS             ON            3.5
## 97                     JADE GE             MI            3.5
## 100     MICHAEL JEFFERY THOMAS             MI            3.5
## 103           JOSHUA DAVID LEE             MI            3.5
## 106              SIDDHARTH JHA             MI            3.5
## 109       AMIYATOSH PWNANANDAM             MI            3.5
## 112                  BRIAN LIU             MI            3.0
## 115              JOEL R HENDON             MI            3.0
## 118               FOREST ZHANG             MI            3.0
## 121        KYLE WILLIAM MURPHY             MI            3.0
## 124                   JARED GE             MI            3.0
## 127          ROBERT GLEN VASEY             MI            3.0
## 130         JUSTIN D SCHILLING             MI            3.0
## 133                  DEREK YAN             MI            3.0
## 136   JACOB ALEXANDER LAVALLEY             MI            3.0
## 139                ERIC WRIGHT             MI            2.5
## 142               DANIEL KHAIN             MI            2.5
## 145           MICHAEL J MARTIN             MI            2.5
## 148                 SHIVAM JHA             MI            2.5
## 151             TEJAS AYYAGARI             MI            2.5
## 154                  ETHAN GUO             MI            2.5
## 157              JOSE C YBARRA             MI            2.0
## 160                LARRY HODGE             MI            2.0
## 163                  ALEX KONG             MI            2.0
## 166               MARISA RICCI             MI            2.0
## 169                 MICHAEL LU             MI            2.0
## 172               VIRAJ MOHILE             MI            2.0
## 175          SEAN M MC CORMICK             MI            2.0
## 178                 JULIA SHEN             MI            1.5
## 181              JEZZEL FARKAS             ON            1.5
## 184              ASHWIN BALAJI             MI            1.0
## 187       THOMAS JOSEPH HOSMER             MI            1.0
## 190                     BEN LI             MI            1.0
##     Player's Pre-Tourney Rating Avg Pre-Tourney Opponent Rating
## 11                         1794                              27
## 4                          1553                              24
## 7                          1384                              47
## 10                         1716                              42
## 13                         1655                              38
## 16                         1686                              37
## 19                         1649                              38
## 22                         1641                              36
## 25                         1411                              35
## 28                         1365                              35
## 31                         1712                              35
## 34                         1663                              44
## 37                         1666                              35
## 40                         1610                              29
## 43                         1220                              30
## 46                         1604                              58
## 49                         1629                              35
## 52                         1600                              30
## 55                         1564                              26
## 58                         1595                              35
## 61                         1563                              21
## 64                         1555                              44
## 67                         1363                              28
## 70                         1229                              28
## 73                         1745                              30
## 76                         1579                              28
## 79                         1552                              48
## 82                         1507                              39
## 85                         1602                              30
## 88                         1522                              23
## 91                         1494                              31
## 94                         1441                              33
## 97                         1449                              30
## 100                        1399                              26
## 103                        1438                              14
## 106                        1355                              46
## 109                         980                              58
## 112                        1423                              56
## 115                        1436                              24
## 118                        1348                              26
## 121                        1403                              89
## 124                        1332                              16
## 127                        1283                              36
## 130                        1199                              41
## 133                        1242                              19
## 136                         377                              32
## 139                        1362                              52
## 142                        1382                              52
## 145                        1291                              55
## 148                        1056                              38
## 151                        1011                              35
## 154                         935                              39
## 157                        1393                             115
## 160                        1270                              44
## 163                        1186                              37
## 166                        1153                              55
## 169                        1092                              47
## 172                         917                              50
## 175                         853                              35
## 178                         967                              55
## 181                         955                              30
## 184                        1530                             356
## 187                        1175                              48
## 190                        1163                              37