validateBallots: Validates Input Data Format for 'stv()'.

Description Usage Arguments Details Value Examples

Description

Validates data format for stv() input. Assumes each row and column corresponds to a ballot and candidate respectively. See details for the tests run by this function. If input data is in correct format, returns string: "All tests passed. Please feel free to run stv() function.". Otherwise, prints corresponding warning message.

Usage

1

Arguments

x

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

Details

Checks if input data is in acceptable format for stv(). User must run this function before calling stv(). Before any calculation, stv() calls this function and proceeds only if x passes all of the following tests (run in given order).

  1. If x is a data.frame.

  2. If x has unique column names.

  3. If x has numeric entries.

  4. If x doesn't have any blank column.

  5. If x doesn't have any blank row or a row with non-sequential ranks.

Value

string: "All tests passed. Please feel free to run stv() function." if x passes all tests. Otherwise, corresponding warning message. NOTE: Some of the warnings can be fixed using cleanBallots() function. Other issues must be fixed by the user.

Examples

1
2
3
data(ballots)
result <- try(validateBallots(ballots), silent=TRUE)
print(result)

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