Learn R Programming

ClimMobTools (version 0.2-7)

build_rankings: Build Plackett-Luce rankings

Description

Create an object of class "rankings" from ClimMob data

Usage

build_rankings(data = NULL, items = NULL, input = NULL,
  additional.rank = NULL, group = FALSE, ...)

Arguments

data

a data frame with columns specified by items and input values to rank.

items

a data frame or index of data for the column(s) containing the item names

input

a data frame or index of data for the column(s) containing the values to be ranked

additional.rank

optional, a data frame for the comparisons between tricot items and the local item

group

logical, if TRUE return an object of class "grouped_rankings"

...

additional arguments passed to methods. See details

Value

a PlackettLuce "rankings" object, which is a matrix of dense rankings

Details

full.output: logical, to return a list with a "rankings", a "grouped_rankings" and the ordered items

See Also

rankings

Examples

Run this code
# NOT RUN {
 
# beans data where each observer compares 3 varieties randomly distributed 
# from a list of 11 and additionally compares these 3 varieties 
# with their local variety
library("PlackettLuce")
data("beans", package = "PlackettLuce")

# first build rankings with only tricot items
# and return an object of class 'rankings'
R <- build_rankings(data = beans,
                    items = c(1:3),
                    input = c(4:5))
head(R)

############################################################

# pass the comparison with local item as an additional rankings, then
# each of the 3 varieties are compared separately with the local item
# and return an object of class grouped_rankings
G <- build_rankings(data = beans,
                    items = c(1:3),
                    input = c(4:5),
                    additional.rank = beans[c(6:8)],
                    group = TRUE)
                    
head(G)

############################################################

# rankings with five items in a ClimMob project

items <- randomise(5, 5, 5, c("green","blue","red","white","yellow"))

input <- as.data.frame(matrix(NA, nrow = 5, ncol = 5))
names(input) <- paste0("position_item_",LETTERS[1:5])

for(s in 1:5) {
  input[s,] <- sample(1:5)
}

build_rankings(items = items, 
               input = input)


# }

Run the code above in your browser using DataLab