Computes how well a user's ranking matches the correct ranking using the Kendall tau distance. Counts concordant pairs (user agrees with correct order) vs discordant pairs (user disagrees).
Value
A list with:
score: number of concordant pairsmax_score: total number of pairs = k*(k-1)/2n_concordant: same as scoren_discordant: pairs where user and correct order disagreepct: percentage score (0-100)
Examples
# Perfect score
kendall_tau_score(c(1, 2, 3), c(1, 2, 3))
#> $score
#> [1] 3
#>
#> $max_score
#> [1] 3
#>
#> $n_concordant
#> [1] 3
#>
#> $n_discordant
#> [1] 0
#>
#> $pct
#> [1] 100
#>
# Completely reversed
kendall_tau_score(c(3, 2, 1), c(1, 2, 3))
#> $score
#> [1] 0
#>
#> $max_score
#> [1] 3
#>
#> $n_concordant
#> [1] 0
#>
#> $n_discordant
#> [1] 3
#>
#> $pct
#> [1] 0
#>
# One swap
kendall_tau_score(c(2, 1, 3), c(1, 2, 3))
#> $score
#> [1] 2
#>
#> $max_score
#> [1] 3
#>
#> $n_concordant
#> [1] 2
#>
#> $n_discordant
#> [1] 1
#>
#> $pct
#> [1] 66.7
#>
