knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(consensus)

Creating rankings

There are three

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
r2 <- c(3, 8, 1, 2, 5)
names(r2) <- letters[1:5]
r2 <- ranking(r2)
r2
r3 <- c(3, 8, 1, 2, 5)
names(r3) <- c(letters[1:4], letters[1])
r3 <- ranking(r3)
r3
r4 <- c(3, 8, 1, 2, 5)
r4
r5 <- c(3, 1, 1, 3, 3)
names(r5) <- letters[1:5]
r5
as.numeric(r1)
is.ranking(r1)
as.numeric(r2)
is.ranking(r2)
as.numeric(r3)
is.ranking(r3)
as.numeric(r4)
is.ranking(r4)
as.numeric(r5)
is.ranking(r5)

parse_ranking

Errors

Checking that an object is a ranking



noeliarico/consensus documentation built on March 18, 2023, 12:37 p.m.