cleanBallots: Tries to Address 'validateBallots()' Warning(s).

Description Usage Arguments Details Value Examples

Description

Tries to clean data for stv(). Some of the warnings from validateBallots() have to addressed by the user (see Details).

Usage

1
cleanBallots(x, cand.names = NULL)

Arguments

x

a data.frame with rows as ballots and columns as candidates.

cand.names

character vector of length equal to number of candidates (needed when column names of x are missing or not unique).

Details

Assumes x contains rows and columns corresponding to ballots and candidates respectively. Tries to address issues raised by validateBallots() in the following order:

  1. If x is a matrix then converts to data.frame. Otherwise, user has to convert x into data.frame.

  2. Checks if x has numeric entries. If not, checks if numeric data was passed as character. If this also fails, then user has to convert data into numeric type.

  3. If column names of x are missing assigns cand.names as column names. If x already has valid column names, no need to specify cand.names. If column names of x missing and cand.names not specified, returns error message.

  4. Removes blank columns.

  5. Removes blank and/or non-sequentially ranked rows.

Value

a data.frame compatible for stv() function.

Examples

1
2
3

chandrasaksham/STV documentation built on May 20, 2019, 2:24 p.m.