# as_complete: Convert Incomplete ranking/rating matrix into full matrix In votesys: Voting Systems, Instant-Runoff Voting, Borda Method, Various Condorcet Methods

## 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.

• (1) "valid": the default method. For the vector `c(3, 1, 2, 2, NA, NA)`, as there should be 6 values but only 4 are given, 4 is the valid number, and the NAs will be converted to 4. However, if the argument `plus` is a value other than 0, than NAs will be equal to the valid number plus that value. For example, if `plus = 10`, the NAs will be 14 (4 + 10).

• (2) "max": the maximum value in each row plus the value given by `plus`. So for `c(3, 1, 2, 2, NA, NA)`, and `plus = 0`, NAs will be 3 (3 + 0).

• (3) "len": In the case of topKlist, interviewees may, for example, choose 4 or 5 items from a 20-item list. When the method is "len", use `n` to indicate the total number of items or any other number. The default value of `n` is `ncol(x)`, which is equivalent to the way `create_vote` used to convert NAs so as to calculate the Condorcet matrix.

## 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.