Description Usage Arguments Examples
Calculate updated Elo ratings based on existing rating and results from matches
1 2 3 | elo_upd(ra, rb, score, k = 16, sum = length(rb) > 1)
elo_upd_pw(ra, rb, score, k = 16)
|
ra |
rating of player A |
rb |
rating of player B |
score |
score respective to player A. Numeric or character; 1, 0.5, 0; win, tie, loss |
k |
a measure of how big the correction should be |
sum |
calculate the new rating based on sum of scores and opponents ratings |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # as in example from
# https://en.wikipedia.org/wiki/Elo_rating_system#Mathematical_details
# per 2019-10-04
ra <- 1613
rb <- c(1609, 1477, 1388, 1586, 1720)
score <- c(0, 0.5, 1, 1, 0)
elo_upd(ra, rb, score, k=32, sum=FALSE)
elo_upd(ra, rb, score, k=32, sum=TRUE)
elo_upd_pw(c(1400, 1500), c(1300, 1400), c("w", "t"))
results <- read.table(text="
Player1 Player2 Result
Alice Bob Win
Charlie Dennis Loss
Elena Frank Loss
June Rashida Tie", header=TRUE, stringsAsFactors=FALSE)
scores <- read.table(text="
Player Score
Alice 1150
Charlie 1150
Frank 1150
Bob 800
Dennis 800
Elena 800
June 900
Rashida 1100", header=TRUE, stringsAsFactors=FALSE)
rownames(scores) <- scores$Player
r2 <- results
r2[,1:2] <- scores[as.matrix(r2[,1:2]), 2]
r2u <- elo_upd_pw(r2)
scores.new <- data.frame(Score=c(r2u))
rownames(scores.new) <- as.matrix(results[,1:2])
scores.new <- round(scores.new[rownames(scores),, drop=FALSE])
scores.new$diff <- scores.new$Score - scores$Score
scores.new
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.