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

Description Usage Arguments Details Value Examples

View source: R/validate_clean_ballots.R

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

1

Arguments

x

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

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.

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.

Examples

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

STV documentation built on May 2, 2019, 4:01 a.m.