Group and coerce numeric values into Plackett-Luce rankings.
rank_numeric(
data,
items,
input,
id = NULL,
group = FALSE,
ascending = FALSE,
...
)a data.frame with columns specified by items and input values
a character or numerical vector for indexing the column(s)
containing the item names in data
a character or numerical vector for indexing the column(s)
containing the values in data to be ranked
an index of data indicating the
ids for "long" data
logical, if TRUE return an object of class "grouped_rankings"
logical, only for floating point numbers, to compute rankings from lower to higher values
additional arguments passed to methods
a PlackettLuce "rankings" object, which is a matrix of dense rankings
Other rank functions:
rank_tricot(),
rank_tricot2(),
set_binomialfreq(),
set_paircomp()
# A matrix with 10 rankings of 5 items (A, B, C, D, E)
# with numeric values as "rank"
set.seed(123)
df = cbind(id = rep(1:10, each = 5),
items = rep(LETTERS[1:5], times = 10),
input = runif(50, 1, 3))
# return an object of class 'rankings'
R = rank_numeric(df,
items = 2,
input = 3,
id = 1)
#> Warning: `rank_numeric()` was deprecated in gosset 1.5.1.
#> ℹ Please use `rank_tricot2()` instead.
#> ℹ rank_numeric() is deprecated for tricot data. Use rank_tricot2(), which
#> optmizes tricot block/item order and sparse inputs.
#> id was identified as 'character' and was coerced to 'integer'
# rankings can be computed in ascending order
R = rank_numeric(df,
items = 2,
input = 3,
id = 1,
ascending = TRUE)
#> id was identified as 'character' and was coerced to 'integer'
# return an object of class 'grouped_rankings'
R = rank_numeric(df,
items = 2,
input = 3,
id = 1,
group = TRUE)
#> id was identified as 'character' and was coerced to 'integer'