library(consensus)

Creating rankings

There are three

  • ranking
  • parse_ranking

ranking()

v cname decreasing output
Opt1 x - - Ranks the numbers in v in ascending order giving them the defaults names \(c_1, c_2, ..., c_n\). If v is a named vector…
Opt2 x - x
Opt3 x x -
Opt4 x x x
- - x ERROR
- x - ERROR
- x x ERROR

The function ranking

Objects of class ranking are represented with “≻”. Given two candidates \(c_1\) and \(c_2\) and the ranking \(c_1 \succ c_2\) this must be read as "\(c_1\) is better than \(c_2\). This is, \(c_1\) is ranked in a better position than \(c_2\).

There are three options

  1. Candidates for the names are given
  2. Candidates for the names are not give
r1 <- c(3, 8, 1, 2, 5)
r1 <- ranking(r1)
r1
#> C3 ≻ C4 ≻ C1 ≻ C5 ≻ C2
r2 <- c(3, 8, 1, 2, 5)
names(r2) <- letters[1:5]
r2 <- ranking(r2)
r2
#> c ≻ d ≻ a ≻ e ≻ b
r3 <- c(3, 8, 1, 2, 5)
names(r3) <- c(letters[1:4], letters[1])
r3 <- ranking(r3)
#> Warning in ranking(r3): The names of the v vector
#>                   must be unique for each candidate.
#>                 Default names has been autogenerated to
#>                 accomplish this requirement.
r3
#> C3 ≻ C4 ≻ C1 ≻ C5 ≻ C2
r4 <- c(3, 8, 1, 2, 5)
r4
#> [1] 3 8 1 2 5
r5 <- c(3, 1, 1, 3, 3)
names(r5) <- letters[1:5]
r5
#> a b c d e 
#> 3 1 1 3 3
as.numeric(r1)
#> [1] 3 5 1 2 4
is.ranking(r1)
#> [1] TRUE
as.numeric(r2)
#> [1] 3 5 1 2 4
is.ranking(r2)
#> [1] TRUE
as.numeric(r3)
#> [1] 3 5 1 2 4
is.ranking(r3)
#> [1] TRUE
as.numeric(r4)
#> [1] 3 8 1 2 5
is.ranking(r4)
#> The vector is not a ranking
#> [1] FALSE
as.numeric(r5)
#> [1] 3 1 1 3 3
is.ranking(r5)
#> The vector is not a ranking
#> [1] FALSE

parse_ranking

Errors

  • The argument cnames must be a vector

Checking that an object is a ranking