Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

decode

Decode Orderings using a Key to Item Names


Description

Decode orderings by replacing numeric or character coded values with item names.

Usage

decode(orderings, items, code = NULL)

Arguments

orderings

A data frame of coded orderings.

items

A data frame of the items in each ranking, or a vector of common items.

code

(Optional) a vector giving the key to the code. If missing, names(items) is used for a character code, while seq(items) is used for a numeric code.

Value

A data frame with the coded values replaced by the item names.

Examples

# orderings of up to 3 items coded as A, B, C
orderings <- data.frame(Rank1 = c("A", "B"),
                        Rank2 = c("C", "A"),
                        Rank3 = c("B", NA),
                        stringsAsFactors = FALSE)
items <- data.frame(A = c("banana", "apple"),
                    B = c("orange", "pear"),
                    C = c("apple", NA),
                    stringsAsFactors = FALSE)
decode(orderings, items)

# orderings with ties of up to 3 items, coded 1:3
orderings <- data.frame(Rank1 = c(1, 3),
                        Rank2 = I(list(c(2, 3), 2)),
                        Rank3 = c(NA, 1),
                        stringsAsFactors = FALSE)
items <- data.frame(A = c("banana", "apple"),
                    B = c("orange", "pear"),
                    C = c("apple", "orange"),
                    stringsAsFactors = FALSE)
decode(orderings, items)

# same items in each comparison
items <- c(A = "banana", B = "orange", C = "pear")
decode(orderings, items)

PlackettLuce

Plackett-Luce Models for Rankings

v0.4.0
GPL-3
Authors
Heather Turner [aut, cre] (<https://orcid.org/0000-0002-1256-3375>), Ioannis Kosmidis [aut] (<https://orcid.org/0000-0003-1556-0302>), David Firth [aut] (<https://orcid.org/0000-0003-0302-2312>), Jacob van Etten [ctb] (<https://orcid.org/0000-0001-7554-2558>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.