#' Formats a database of match statistics to be able to find elo ratings.
#'
#' @param stats Database of match statistics, in the form of the MatchStats database.
#' @return A dataset of match results formatted to find elo ratings.
#' @export
MatchResultselo <- function(stats){
MatchResultselo <- stats[c(3,7,8,9)]
names(MatchResultselo)[4] <- "Result"
names(MatchResultselo)[1] <- "Day"
for (j in 1:nrow(MatchResultselo))
{
if(MatchResultselo$Player[[j]] == MatchResultselo$Result[[j]]){
MatchResultselo$Result[[j]] <- 1
} else{
MatchResultselo$Result[[j]] <- 0
}
}
MatchResultselo <- MatchResultselo[which(MatchResultselo$Result==1),]
beginningdate <- as.Date("30.12.2012", "%d.%m.%Y")
MatchResultselo$Day <- MatchResultselo$Day - beginningdate
MatchResultselo$Day <- as.numeric(MatchResultselo$Day)
MatchResultselo$Result <- as.numeric(MatchResultselo$Result)
return(MatchResultselo)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.