In this project, you’re given a text file with chess tournament results where the information has some structure. Your job is to create an R Markdown file that generates a .CSV file (that could for example be imported into a SQL database) with the following information for all of the players: Player’s Name, Player’s State, Total Number of Points, Player’s Pre-Rating, and Average Pre Chess Rating of Opponents For the first player, the information would be: Gary Hua, ON, 6.0, 1794, 1605 1605 was calculated by using the pre-tournament opponents’ ratings of 1436, 1563, 1600, 1610, 1649, 1663, 1716, and dividing by the total number of games played. If you have questions about the meaning of the data or the results, please post them on the discussion forum. Data science, like chess, is a game of back and forth. The chess rating system (invented by a Minnesota statistician named Arpad Elo) has been used in many other contexts, including assessing relative strength of employment candidates by human resource departments.
Loading the required packages and Reading the source file into R. Note here that the tournamentinfo.txt file has been saved in my github link and we will be reading it from here: https://raw.githubusercontent.com/deepakmongia/Fall2018/master/tournamentinfo.txt
##install.packages("readtext")
##install.packages("stringr")
library(readtext)
library(stringr)
getURL <- "https://raw.githubusercontent.com/deepakmongia/Fall2018/master/tournamentinfo.txt"
chess.tournament.txt <- readtext(getURL)
View(chess.tournament.txt)
class(chess.tournament.txt)
## [1] "readtext" "data.frame"
Now as we see above, the raw data frame from the text file is not good to use as such. So we will have to clean it up to make it useful for our exercise.
## Splitting by next line character into a data.frame with multiple rows
chess.tournament.df1 <- as.data.frame(str_split(chess.tournament.txt$text, "\n"))
head(chess.tournament.df1, 20)
## c..............................................................................................
## 1 -----------------------------------------------------------------------------------------
## 2 Pair | Player Name |Total|Round|Round|Round|Round|Round|Round|Round|
## 3 Num | USCF ID / Rtg (Pre->Post) | Pts | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
## 4 -----------------------------------------------------------------------------------------
## 5 1 | GARY HUA |6.0 |W 39|W 21|W 18|W 14|W 7|D 12|D 4|
## 6 ON | 15445895 / R: 1794 ->1817 |N:2 |W |B |W |B |W |B |W |
## 7 -----------------------------------------------------------------------------------------
## 8 2 | DAKSHESH DARURI |6.0 |W 63|W 58|L 4|W 17|W 16|W 20|W 7|
## 9 MI | 14598900 / R: 1553 ->1663 |N:2 |B |W |B |W |B |W |B |
## 10 -----------------------------------------------------------------------------------------
## 11 3 | ADITYA BAJAJ |6.0 |L 8|W 61|W 25|W 21|W 11|W 13|W 12|
## 12 MI | 14959604 / R: 1384 ->1640 |N:2 |W |B |W |B |W |B |W |
## 13 -----------------------------------------------------------------------------------------
## 14 4 | PATRICK H SCHILLING |5.5 |W 23|D 28|W 2|W 26|D 5|W 19|D 1|
## 15 MI | 12616049 / R: 1716 ->1744 |N:2 |W |B |W |B |W |B |B |
## 16 -----------------------------------------------------------------------------------------
## 17 5 | HANSHI ZUO |5.5 |W 45|W 37|D 12|D 13|D 4|W 14|W 17|
## 18 MI | 14601533 / R: 1655 ->1690 |N:2 |B |W |B |W |B |W |B |
## 19 -----------------------------------------------------------------------------------------
## 20 6 | HANSEN SONG |5.0 |W 34|D 29|L 11|W 35|D 10|W 27|W 21|
names(chess.tournament.df1) <- "main_column"
## Removing the non-data lines from the data frame
chess.tournament.df3 <- as.data.frame(chess.tournament.df1[!is.na(str_extract(chess.tournament.df1$main_column, ".?(\\d|\\w)")), ])
head(chess.tournament.df3, 20)
## chess.tournament.df1[!is.na(str_extract(chess.tournament.df1$main_column, ".?(\\\\d|\\\\w)")), ]
## 1 Pair | Player Name |Total|Round|Round|Round|Round|Round|Round|Round|
## 2 Num | USCF ID / Rtg (Pre->Post) | Pts | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
## 3 1 | GARY HUA |6.0 |W 39|W 21|W 18|W 14|W 7|D 12|D 4|
## 4 ON | 15445895 / R: 1794 ->1817 |N:2 |W |B |W |B |W |B |W |
## 5 2 | DAKSHESH DARURI |6.0 |W 63|W 58|L 4|W 17|W 16|W 20|W 7|
## 6 MI | 14598900 / R: 1553 ->1663 |N:2 |B |W |B |W |B |W |B |
## 7 3 | ADITYA BAJAJ |6.0 |L 8|W 61|W 25|W 21|W 11|W 13|W 12|
## 8 MI | 14959604 / R: 1384 ->1640 |N:2 |W |B |W |B |W |B |W |
## 9 4 | PATRICK H SCHILLING |5.5 |W 23|D 28|W 2|W 26|D 5|W 19|D 1|
## 10 MI | 12616049 / R: 1716 ->1744 |N:2 |W |B |W |B |W |B |B |
## 11 5 | HANSHI ZUO |5.5 |W 45|W 37|D 12|D 13|D 4|W 14|W 17|
## 12 MI | 14601533 / R: 1655 ->1690 |N:2 |B |W |B |W |B |W |B |
## 13 6 | HANSEN SONG |5.0 |W 34|D 29|L 11|W 35|D 10|W 27|W 21|
## 14 OH | 15055204 / R: 1686 ->1687 |N:3 |W |B |W |B |B |W |B |
## 15 7 | GARY DEE SWATHELL |5.0 |W 57|W 46|W 13|W 11|L 1|W 9|L 2|
## 16 MI | 11146376 / R: 1649 ->1673 |N:3 |W |B |W |B |B |W |W |
## 17 8 | EZEKIEL HOUGHTON |5.0 |W 3|W 32|L 14|L 9|W 47|W 28|W 19|
## 18 MI | 15142253 / R: 1641P17->1657P24 |N:3 |B |W |B |W |B |W |W |
## 19 9 | STEFANO LEE |5.0 |W 25|L 18|W 59|W 8|W 26|L 7|W 20|
## 20 ON | 14954524 / R: 1411 ->1564 |N:2 |W |B |W |B |W |B |B |
names(chess.tournament.df3) <- "main_column"
## Selecting only the data rows or removing the 2 header rows
chess.tournament.df4 <- as.data.frame(chess.tournament.df3[substr(chess.tournament.df3$main_column, 1, 2) ==" ", ])
head(chess.tournament.df4, 20)
## chess.tournament.df3[substr(chess.tournament.df3$main_column, 1, 2) == " ", ]
## 1 1 | GARY HUA |6.0 |W 39|W 21|W 18|W 14|W 7|D 12|D 4|
## 2 ON | 15445895 / R: 1794 ->1817 |N:2 |W |B |W |B |W |B |W |
## 3 2 | DAKSHESH DARURI |6.0 |W 63|W 58|L 4|W 17|W 16|W 20|W 7|
## 4 MI | 14598900 / R: 1553 ->1663 |N:2 |B |W |B |W |B |W |B |
## 5 3 | ADITYA BAJAJ |6.0 |L 8|W 61|W 25|W 21|W 11|W 13|W 12|
## 6 MI | 14959604 / R: 1384 ->1640 |N:2 |W |B |W |B |W |B |W |
## 7 4 | PATRICK H SCHILLING |5.5 |W 23|D 28|W 2|W 26|D 5|W 19|D 1|
## 8 MI | 12616049 / R: 1716 ->1744 |N:2 |W |B |W |B |W |B |B |
## 9 5 | HANSHI ZUO |5.5 |W 45|W 37|D 12|D 13|D 4|W 14|W 17|
## 10 MI | 14601533 / R: 1655 ->1690 |N:2 |B |W |B |W |B |W |B |
## 11 6 | HANSEN SONG |5.0 |W 34|D 29|L 11|W 35|D 10|W 27|W 21|
## 12 OH | 15055204 / R: 1686 ->1687 |N:3 |W |B |W |B |B |W |B |
## 13 7 | GARY DEE SWATHELL |5.0 |W 57|W 46|W 13|W 11|L 1|W 9|L 2|
## 14 MI | 11146376 / R: 1649 ->1673 |N:3 |W |B |W |B |B |W |W |
## 15 8 | EZEKIEL HOUGHTON |5.0 |W 3|W 32|L 14|L 9|W 47|W 28|W 19|
## 16 MI | 15142253 / R: 1641P17->1657P24 |N:3 |B |W |B |W |B |W |W |
## 17 9 | STEFANO LEE |5.0 |W 25|L 18|W 59|W 8|W 26|L 7|W 20|
## 18 ON | 14954524 / R: 1411 ->1564 |N:2 |W |B |W |B |W |B |B |
## 19 10 | ANVIT RAO |5.0 |D 16|L 19|W 55|W 31|D 6|W 25|W 18|
## 20 MI | 14150362 / R: 1365 ->1544 |N:3 |W |W |B |B |W |B |W |
names(chess.tournament.df4) <- "main_column"
## Splitting into columns based on pipe delimiter "|"
elems <- unlist(str_split(chess.tournament.df4$main_column, "\\|"))
chess.tournament.matrix <- matrix(elems, ncol = 11, byrow = TRUE)
head(chess.tournament.matrix, 20)
## [,1] [,2] [,3] [,4] [,5]
## [1,] " 1 " " GARY HUA " "6.0 " "W 39" "W 21"
## [2,] " ON " " 15445895 / R: 1794 ->1817 " "N:2 " "W " "B "
## [3,] " 2 " " DAKSHESH DARURI " "6.0 " "W 63" "W 58"
## [4,] " MI " " 14598900 / R: 1553 ->1663 " "N:2 " "B " "W "
## [5,] " 3 " " ADITYA BAJAJ " "6.0 " "L 8" "W 61"
## [6,] " MI " " 14959604 / R: 1384 ->1640 " "N:2 " "W " "B "
## [7,] " 4 " " PATRICK H SCHILLING " "5.5 " "W 23" "D 28"
## [8,] " MI " " 12616049 / R: 1716 ->1744 " "N:2 " "W " "B "
## [9,] " 5 " " HANSHI ZUO " "5.5 " "W 45" "W 37"
## [10,] " MI " " 14601533 / R: 1655 ->1690 " "N:2 " "B " "W "
## [11,] " 6 " " HANSEN SONG " "5.0 " "W 34" "D 29"
## [12,] " OH " " 15055204 / R: 1686 ->1687 " "N:3 " "W " "B "
## [13,] " 7 " " GARY DEE SWATHELL " "5.0 " "W 57" "W 46"
## [14,] " MI " " 11146376 / R: 1649 ->1673 " "N:3 " "W " "B "
## [15,] " 8 " " EZEKIEL HOUGHTON " "5.0 " "W 3" "W 32"
## [16,] " MI " " 15142253 / R: 1641P17->1657P24 " "N:3 " "B " "W "
## [17,] " 9 " " STEFANO LEE " "5.0 " "W 25" "L 18"
## [18,] " ON " " 14954524 / R: 1411 ->1564 " "N:2 " "W " "B "
## [19,] " 10 " " ANVIT RAO " "5.0 " "D 16" "L 19"
## [20,] " MI " " 14150362 / R: 1365 ->1544 " "N:3 " "W " "W "
## [,6] [,7] [,8] [,9] [,10] [,11]
## [1,] "W 18" "W 14" "W 7" "D 12" "D 4" ""
## [2,] "W " "B " "W " "B " "W " ""
## [3,] "L 4" "W 17" "W 16" "W 20" "W 7" ""
## [4,] "B " "W " "B " "W " "B " ""
## [5,] "W 25" "W 21" "W 11" "W 13" "W 12" ""
## [6,] "W " "B " "W " "B " "W " ""
## [7,] "W 2" "W 26" "D 5" "W 19" "D 1" ""
## [8,] "W " "B " "W " "B " "B " ""
## [9,] "D 12" "D 13" "D 4" "W 14" "W 17" ""
## [10,] "B " "W " "B " "W " "B " ""
## [11,] "L 11" "W 35" "D 10" "W 27" "W 21" ""
## [12,] "W " "B " "B " "W " "B " ""
## [13,] "W 13" "W 11" "L 1" "W 9" "L 2" ""
## [14,] "W " "B " "B " "W " "W " ""
## [15,] "L 14" "L 9" "W 47" "W 28" "W 19" ""
## [16,] "B " "W " "B " "W " "W " ""
## [17,] "W 59" "W 8" "W 26" "L 7" "W 20" ""
## [18,] "W " "B " "W " "B " "B " ""
## [19,] "W 55" "W 31" "D 6" "W 25" "W 18" ""
## [20,] "B " "B " "W " "B " "W " ""
## Converting the matrix into a data.frame
chess.data.frame1 <- as.data.frame(chess.tournament.matrix)
## Creating a new data.frame with only the first row out of 2 rows for each player information
chess.data.frame2 <- chess.data.frame1[!is.na(str_extract(chess.data.frame1$V1, "^ +\\d+")), ]
## The state and the pre-score needs to come from the 2nd row for each of the player. Hence we are using this code to create a new column to have the state.
chess.data.frame2$State <- chess.data.frame1[is.na(str_extract(chess.data.frame1$V1, "^ +\\d+")), 1]
## Pulling the whole string from the 2nd row which has the pre-rating, into the new array
chess.data.frame2$Pre.rating <- chess.data.frame1[is.na(str_extract(chess.data.frame1$V1, "^ +\\d+")), 2]
## Now this pre.rating column has other data as well - USCF ID, pre-rating and post-rating. We need only the pre-rating for our data analysis. So, we will break it so that we can only have the pre-rating value in this column
chess.data.frame2$Pre.rating <- str_extract(chess.data.frame2$Pre.rating, "R\\: +\\d+")
chess.data.frame2$Pre.rating <- str_extract(chess.data.frame2$Pre.rating, "\\d+")
chess.data.frame2$Pre.rating <- as.numeric(chess.data.frame2$Pre.rating)
names(chess.data.frame2) <- c("Player.Id", "Name", "Total.Points", "Round.1", "Round.2", "Round.3", "Round.4", "Round.5", "Round.6", "Round.7", "Blank.field", "State", "Pre.rating")
chess.data.frame2$Player.Id <- as.numeric(chess.data.frame2$Player.Id)
chess.data.frame2$Round.1 <- as.character(chess.data.frame2$Round.1)
chess.data.frame2$Round.2 <- as.character(chess.data.frame2$Round.2)
chess.data.frame2$Round.3 <- as.character(chess.data.frame2$Round.3)
chess.data.frame2$Round.4 <- as.character(chess.data.frame2$Round.4)
chess.data.frame2$Round.5 <- as.character(chess.data.frame2$Round.5)
chess.data.frame2$Round.6 <- as.character(chess.data.frame2$Round.6)
chess.data.frame2$Round.7 <- as.character(chess.data.frame2$Round.7)
head(chess.data.frame2, 20)
## Player.Id Name Total.Points Round.1
## 1 1 GARY HUA 6.0 W 39
## 3 2 DAKSHESH DARURI 6.0 W 63
## 5 3 ADITYA BAJAJ 6.0 L 8
## 7 4 PATRICK H SCHILLING 5.5 W 23
## 9 5 HANSHI ZUO 5.5 W 45
## 11 6 HANSEN SONG 5.0 W 34
## 13 7 GARY DEE SWATHELL 5.0 W 57
## 15 8 EZEKIEL HOUGHTON 5.0 W 3
## 17 9 STEFANO LEE 5.0 W 25
## 19 10 ANVIT RAO 5.0 D 16
## 21 11 CAMERON WILLIAM MC LEMAN 4.5 D 38
## 23 12 KENNETH J TACK 4.5 W 42
## 25 13 TORRANCE HENRY JR 4.5 W 36
## 27 14 BRADLEY SHAW 4.5 W 54
## 29 15 ZACHARY JAMES HOUGHTON 4.5 D 19
## 31 16 MIKE NIKITIN 4.0 D 10
## 33 17 RONALD GRZEGORCZYK 4.0 W 48
## 35 18 DAVID SUNDEEN 4.0 W 47
## 37 19 DIPANKAR ROY 4.0 D 15
## 39 20 JASON ZHENG 4.0 L 40
## Round.2 Round.3 Round.4 Round.5 Round.6 Round.7 Blank.field State
## 1 W 21 W 18 W 14 W 7 D 12 D 4 ON
## 3 W 58 L 4 W 17 W 16 W 20 W 7 MI
## 5 W 61 W 25 W 21 W 11 W 13 W 12 MI
## 7 D 28 W 2 W 26 D 5 W 19 D 1 MI
## 9 W 37 D 12 D 13 D 4 W 14 W 17 MI
## 11 D 29 L 11 W 35 D 10 W 27 W 21 OH
## 13 W 46 W 13 W 11 L 1 W 9 L 2 MI
## 15 W 32 L 14 L 9 W 47 W 28 W 19 MI
## 17 L 18 W 59 W 8 W 26 L 7 W 20 ON
## 19 L 19 W 55 W 31 D 6 W 25 W 18 MI
## 21 W 56 W 6 L 7 L 3 W 34 W 26 MI
## 23 W 33 D 5 W 38 H D 1 L 3 MI
## 25 W 27 L 7 D 5 W 33 L 3 W 32 MI
## 27 W 44 W 8 L 1 D 27 L 5 W 31 MI
## 29 L 16 W 30 L 22 W 54 W 33 W 38 MI
## 31 W 15 H W 39 L 2 W 36 U MI
## 33 W 41 L 26 L 2 W 23 W 22 L 5 MI
## 35 W 9 L 1 W 32 L 19 W 38 L 10 MI
## 37 W 10 W 52 D 28 W 18 L 4 L 8 MI
## 39 W 49 W 23 W 41 W 28 L 2 L 9 MI
## Pre.rating
## 1 1794
## 3 1553
## 5 1384
## 7 1716
## 9 1655
## 11 1686
## 13 1649
## 15 1641
## 17 1411
## 19 1365
## 21 1712
## 23 1663
## 25 1666
## 27 1610
## 29 1220
## 31 1604
## 33 1629
## 35 1600
## 37 1564
## 39 1595
Now we have all the columns that are required. The final data.frame needs the below columns: Name State Total.Points Pre-rating Average Pre-rating of opponents
So, we have all the required columns + extra columns. But we have to yet find the average pre-rating of the opponents for each player. This will be achieved through a function as defined below.
average.rating.func <- function(player_id)
{
average_rating <- 0
sum_opponents <- 0
k <- 0
## Round1
a <- str_extract(chess.data.frame2$Round.1[player_id], "\\w+ +\\d+")
if(!is.na(a))
{
b <- str_extract(a, "\\d+")
k <- k + 1
sum_opponents <- sum_opponents + chess.data.frame2$Pre.rating[chess.data.frame2$Player.Id == as.numeric(b)]
}
## Round2
a <- str_extract(chess.data.frame2$Round.2[player_id], "\\w+ +\\d+")
if(!is.na(a))
{
b <- str_extract(a, "\\d+")
k <- k + 1
sum_opponents <- sum_opponents + chess.data.frame2$Pre.rating[chess.data.frame2$Player.Id == as.numeric(b)]
}
## Round3
a <- str_extract(chess.data.frame2$Round.3[player_id], "\\w+ +\\d+")
if(!is.na(a))
{
b <- str_extract(a, "\\d+")
k <- k + 1
sum_opponents <- sum_opponents + chess.data.frame2$Pre.rating[chess.data.frame2$Player.Id == as.numeric(b)]
}
## Round4
a <- str_extract(chess.data.frame2$Round.4[player_id], "\\w+ +\\d+")
if(!is.na(a))
{
b <- str_extract(a, "\\d+")
k <- k + 1
sum_opponents <- sum_opponents + chess.data.frame2$Pre.rating[chess.data.frame2$Player.Id == as.numeric(b)]
}
## Round5
a <- str_extract(chess.data.frame2$Round.5[player_id], "\\w+ +\\d+")
if(!is.na(a))
{
b <- str_extract(a, "\\d+")
k <- k + 1
sum_opponents <- sum_opponents + chess.data.frame2$Pre.rating[chess.data.frame2$Player.Id == as.numeric(b)]
}
## Round6
a <- str_extract(chess.data.frame2$Round.6[player_id], "\\w+ +\\d+")
if(!is.na(a))
{
b <- str_extract(a, "\\d+")
k <- k + 1
sum_opponents <- sum_opponents + chess.data.frame2$Pre.rating[chess.data.frame2$Player.Id == as.numeric(b)]
}
## Round7
a <- str_extract(chess.data.frame2$Round.7[player_id], "\\w+ +\\d+")
if(!is.na(a))
{
b <- str_extract(a, "\\d+")
k <- k + 1
sum_opponents <- sum_opponents + chess.data.frame2$Pre.rating[chess.data.frame2$Player.Id == as.numeric(b)]
}
## Average Pre-Rating of opponents
average_rating <- round(sum_opponents/k, 0)
return(average_rating)
}
Now that we have a function ready to calculate the average pre-rating of the opponents knowing if a player id is passed into the function as an input parameter. We will utilize the lapply function, which takes in a vector and applies a function on each element of the vector and gives the function output as a resulting vector.
chess.data.frame2$Avg.pre.rating.opponents <- unlist(lapply(chess.data.frame2$Player.Id, average.rating.func))
head(chess.data.frame2)
## Player.Id Name Total.Points Round.1
## 1 1 GARY HUA 6.0 W 39
## 3 2 DAKSHESH DARURI 6.0 W 63
## 5 3 ADITYA BAJAJ 6.0 L 8
## 7 4 PATRICK H SCHILLING 5.5 W 23
## 9 5 HANSHI ZUO 5.5 W 45
## 11 6 HANSEN SONG 5.0 W 34
## Round.2 Round.3 Round.4 Round.5 Round.6 Round.7 Blank.field State
## 1 W 21 W 18 W 14 W 7 D 12 D 4 ON
## 3 W 58 L 4 W 17 W 16 W 20 W 7 MI
## 5 W 61 W 25 W 21 W 11 W 13 W 12 MI
## 7 D 28 W 2 W 26 D 5 W 19 D 1 MI
## 9 W 37 D 12 D 13 D 4 W 14 W 17 MI
## 11 D 29 L 11 W 35 D 10 W 27 W 21 OH
## Pre.rating Avg.pre.rating.opponents
## 1 1794 1605
## 3 1553 1469
## 5 1384 1564
## 7 1716 1574
## 9 1655 1501
## 11 1686 1519
Creating the final data.frame with only the columns that are required, and renumbering so the row numbers are in order.
chess.final.data.frame <- chess.data.frame2[, c("Name", "State", "Total.Points", "Pre.rating", "Avg.pre.rating.opponents")]
row.names(chess.final.data.frame) <- 1:nrow(chess.final.data.frame)
chess.final.data.frame
## Name State Total.Points Pre.rating
## 1 GARY HUA ON 6.0 1794
## 2 DAKSHESH DARURI MI 6.0 1553
## 3 ADITYA BAJAJ MI 6.0 1384
## 4 PATRICK H SCHILLING MI 5.5 1716
## 5 HANSHI ZUO MI 5.5 1655
## 6 HANSEN SONG OH 5.0 1686
## 7 GARY DEE SWATHELL MI 5.0 1649
## 8 EZEKIEL HOUGHTON MI 5.0 1641
## 9 STEFANO LEE ON 5.0 1411
## 10 ANVIT RAO MI 5.0 1365
## 11 CAMERON WILLIAM MC LEMAN MI 4.5 1712
## 12 KENNETH J TACK MI 4.5 1663
## 13 TORRANCE HENRY JR MI 4.5 1666
## 14 BRADLEY SHAW MI 4.5 1610
## 15 ZACHARY JAMES HOUGHTON MI 4.5 1220
## 16 MIKE NIKITIN MI 4.0 1604
## 17 RONALD GRZEGORCZYK MI 4.0 1629
## 18 DAVID SUNDEEN MI 4.0 1600
## 19 DIPANKAR ROY MI 4.0 1564
## 20 JASON ZHENG MI 4.0 1595
## 21 DINH DANG BUI ON 4.0 1563
## 22 EUGENE L MCCLURE MI 4.0 1555
## 23 ALAN BUI ON 4.0 1363
## 24 MICHAEL R ALDRICH MI 4.0 1229
## 25 LOREN SCHWIEBERT MI 3.5 1745
## 26 MAX ZHU ON 3.5 1579
## 27 GAURAV GIDWANI MI 3.5 1552
## 28 SOFIA ADINA STANESCU-BELLU MI 3.5 1507
## 29 CHIEDOZIE OKORIE MI 3.5 1602
## 30 GEORGE AVERY JONES ON 3.5 1522
## 31 RISHI SHETTY MI 3.5 1494
## 32 JOSHUA PHILIP MATHEWS ON 3.5 1441
## 33 JADE GE MI 3.5 1449
## 34 MICHAEL JEFFERY THOMAS MI 3.5 1399
## 35 JOSHUA DAVID LEE MI 3.5 1438
## 36 SIDDHARTH JHA MI 3.5 1355
## 37 AMIYATOSH PWNANANDAM MI 3.5 980
## 38 BRIAN LIU MI 3.0 1423
## 39 JOEL R HENDON MI 3.0 1436
## 40 FOREST ZHANG MI 3.0 1348
## 41 KYLE WILLIAM MURPHY MI 3.0 1403
## 42 JARED GE MI 3.0 1332
## 43 ROBERT GLEN VASEY MI 3.0 1283
## 44 JUSTIN D SCHILLING MI 3.0 1199
## 45 DEREK YAN MI 3.0 1242
## 46 JACOB ALEXANDER LAVALLEY MI 3.0 377
## 47 ERIC WRIGHT MI 2.5 1362
## 48 DANIEL KHAIN MI 2.5 1382
## 49 MICHAEL J MARTIN MI 2.5 1291
## 50 SHIVAM JHA MI 2.5 1056
## 51 TEJAS AYYAGARI MI 2.5 1011
## 52 ETHAN GUO MI 2.5 935
## 53 JOSE C YBARRA MI 2.0 1393
## 54 LARRY HODGE MI 2.0 1270
## 55 ALEX KONG MI 2.0 1186
## 56 MARISA RICCI MI 2.0 1153
## 57 MICHAEL LU MI 2.0 1092
## 58 VIRAJ MOHILE MI 2.0 917
## 59 SEAN M MC CORMICK MI 2.0 853
## 60 JULIA SHEN MI 1.5 967
## 61 JEZZEL FARKAS ON 1.5 955
## 62 ASHWIN BALAJI MI 1.0 1530
## 63 THOMAS JOSEPH HOSMER MI 1.0 1175
## 64 BEN LI MI 1.0 1163
## Avg.pre.rating.opponents
## 1 1605
## 2 1469
## 3 1564
## 4 1574
## 5 1501
## 6 1519
## 7 1372
## 8 1468
## 9 1523
## 10 1554
## 11 1468
## 12 1506
## 13 1498
## 14 1515
## 15 1484
## 16 1386
## 17 1499
## 18 1480
## 19 1426
## 20 1411
## 21 1470
## 22 1300
## 23 1214
## 24 1357
## 25 1363
## 26 1507
## 27 1222
## 28 1522
## 29 1314
## 30 1144
## 31 1260
## 32 1379
## 33 1277
## 34 1375
## 35 1150
## 36 1388
## 37 1385
## 38 1539
## 39 1430
## 40 1391
## 41 1248
## 42 1150
## 43 1107
## 44 1327
## 45 1152
## 46 1358
## 47 1392
## 48 1356
## 49 1286
## 50 1296
## 51 1356
## 52 1495
## 53 1345
## 54 1206
## 55 1406
## 56 1414
## 57 1363
## 58 1391
## 59 1319
## 60 1330
## 61 1327
## 62 1186
## 63 1350
## 64 1263
Writing into a csv file on a local drive, which is as given by getwd below.
getwd()
## [1] "C:/Deepak/Deepak Data/MS/CUNY/CUNY MSDS/Fall 2018/DATA 607/DATA 607 Week-4"
write.table(chess.final.data.frame, file = "Chess_Tournament_Deepak_Mongia.csv", sep = ",", col.names = TRUE, row.names = FALSE)