validateBallots {STV} | R Documentation |
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 |
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.
If
x
is adata.frame
.If
x
has unique column names.If
x
has numeric entries.If
x
doesn't have any blank columns.If
x
doesn't have any blank rows.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
data(ballots)
result <- try(validateBallots(ballots), silent=TRUE)
print(result)