| cleanBallots {STV} | R Documentation |
Tries to Address validateBallots() Warning(s).
Description
The cleanBallots() function tries to clean data for use in stv().
Some warnings from validateBallots() can only be addressed by the user.
Usage
cleanBallots(x, cand.names = NULL)
Arguments
x |
a |
cand.names |
character vector of length equal to number of candidates
(needed when column names of |
Details
The cleanBallots() function assumes x contains rows and columns
corresponding to ballots and candidates respectively. Formatting corrections
are attempted in the following order:
If
xis amatrixit is convered to adata.frame. Otherwise, user must provide adata.frame.If
xhas non-numeric entries, user must convert data to numeric type.If
cand.namesis specified, it is assigned as column names ofx. All collumn names must be uniquely specified.xalready has valid column names, no need to specifycand.names. If column names ofxmissing andcand.namesnot specified, returns error message.Removes blank columns.
Removes blank and/or non-sequentially ranked rows.
Value
a data.frame compatible for stv() function.
Examples
data(ballots)
cballots <- cleanBallots(ballots)
validateBallots(cballots)