as_complete: Convert Incomplete ranking/rating matrix into full matrix

Description Usage Arguments Details Value Examples

View source: R/as_complete.R

Description

This function deals with incomplete ranking and rating matrix (e. g., created by create_vote and stored in $ballot), so as to convert it into full ranking and rating. In each row of the score matrix, the smallest value represents the most preferred and the biggest value represents the most hated. For the methods used by this function, see Details. See Examples for how to modify an object of class vote created with incomplete data.

Usage

1
as_complete(x, method = c("valid", "max", "len"), plus = 0, n = NULL)

Arguments

x

the score matrix, should be a matrix, data.frame, or data.table.

method

see Details, default is "valid".

plus

see Details, default is 0.

n

see Details, default is 0.

Details

Three methods are used and you should choose according to your need.

Value

Always a matrix. NAs are converted to numbers. However, if all entries in a row of the input data are NAs, then that row will NOT be modified. NOTE: the order of the returned matrix (the 1st row, the 2nd row, the 3rd row, etc) is DIFFERENT from the input data.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
raw <- list2ballot(string = c("1: a, b, c", "2: b, c", "3: a, b"))
vote <- create_vote(raw, xtype = 3, candidate = c("a", "b", "c"))
ballot <- as_complete(vote$ballot, method = "max", plus = 5)
ballot <- as_complete(vote$ballot, method = "len", n = 10)
# Now re-create the vote object
vote <- create_vote(ballot, xtype = 1)

m <- matrix(c(
    1, 2, 3, NA, NA, NA,
    1, 1.1, 2.2, 8.8, NA, NA, 
    1, 1.1, 2.2, 8.8, NA, NA, 
    1, 1.1, 2.2, 8.8, NA, NA, 
    1, 1.1, 2.2, 8.8, NA, NA, 		
    NA, NA, NA, NA, NA, NA,
    3, 2, NA, NA, NA, NA, 
    3, 2, NA, NA,NA,NA,
    1, 2, 3, 4, 5, 6), ncol = 6, byrow = TRUE)
colnames(m) <- LETTERS[1: 6]
y <- as_complete(m, method = "valid", plus = 30)

votesys documentation built on May 2, 2019, 1:32 p.m.