STV (version 1.0.1)

validateBallots: Validates Input Data Format for stv().

Description

The function validateBallots validates data format for stv() input. It assumes that each row corresponds to a ballot and each column corresponds to a candidate. If input data is in the correct format, validateBallots returns string: "All tests passed. Please feel free to run stv() function." Otherwise, it prints a message corresponding to the formatting error.

Usage

validateBallots(x)

Arguments

x

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

Value

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

Details

The validateBallots function should be run before stv() is called. Before any calculation, stv() calls this function and proceeds only if x passes all of the following tests.

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

  5. If x doesn't have any blank rows.

  6. If x doesn't have any rows with non-sequential ranks.

Examples

Run this code
# NOT RUN {
data(ballots)
result <- try(validateBallots(ballots), silent=TRUE)
print(result)
# }

Run the code above in your browser using DataCamp Workspace