vote-package: Election Vote Counting

Description Details Author(s) Examples

Description

Counting election votes and determining election results by different methods, including the single transferable vote, approval, score and plurality methods.

Details

The main function of the package is called count.votes. If no specific method is passed, it decides on the basis of the available data which method is the most appropriate. Specific methods can also be invoked explicitly. The following voting methods are available:

Output of these functions can be viewed using summary methods, or in a browser using view methods. The summary methods return a data frame which can be stored in a file, see Example below. Functions invalid.votes and valid.votes can be used to check the validity of ballots for the various methods.

Example datasets are included. The ims_election dataset contains anonymized ballots from a past Council election of the Institute of Mathematical Statistics (IMS) which uses the STV method. Modifications of this dataset are available (ims_approval, ims_score, ims_plurality) as examples of data required by the various methods. The food_election dataset taken from Wikipedia can be used to test the STV method.

Author(s)

Hana Sevcikova, Bernard Silverman, Adrian Raftery

Maintainer: Hana Sevcikova

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data(ims_election)
res <- count.votes(ims_election, method = "stv", mcan = 5)
summary(res)

# View invalid votes
invalid.votes(res)

## Not run: 
# View results in a browser
view(res)

# Write election results into a csv file
s <- summary(res)
write.csv(s, "IMSstvresults.csv")
## End(Not run)

Example output

Detected  29 invalid votes. Number of valid votes is 591 .
Use invalid.votes(...) function to view discarded records.

Results of Single transferable vote
===================================                            
Number of valid votes:   591
Number of invalid votes:  29
Number of candidates:     10
Number of seats:           5


|           |      1| 2-trans|       2| 3-trans|      3| 4-trans|      4| 5-trans|      5| 6-trans|      6| 7-trans|      7| 8-trans|       8| 9-trans|       9|
|:----------|------:|-------:|-------:|-------:|------:|-------:|------:|-------:|------:|-------:|------:|-------:|------:|-------:|-------:|-------:|-------:|
|Quota      | 98.501|        |  97.774|        | 97.438|        | 96.938|        | 95.351|        |  95.06|        | 94.684|        |  85.027|        |  83.542|
|Tilmann    |     73|   0.496|  73.496|   0.793| 74.289|   2.016| 76.305|   4.194|   80.5|   3.097| 83.597|   0.271| 83.868|  13.023|  96.891| -11.864|        |
|Julie      |     40|   1.652|  41.652|   2.137| 43.789|    6.33|  50.12|   2.347| 52.466|       6| 58.466|    3.65| 62.117| -62.117|        |        |        |
|Jasper     |    118| -19.499|        |        |       |        |       |        |       |        |       |        |       |        |        |        |        |
|Li         |    104|   4.296| 108.296| -10.523|       |        |       |        |       |        |       |        |       |        |        |        |        |
|Wang       |     20|   0.661|  20.661|   0.226| 20.887| -20.887|       |        |       |        |       |        |       |        |        |        |        |
|Hillary    |     61|   1.818|  62.818|   1.943| 64.761|       0| 64.761|   3.278| 68.039|   5.097| 73.137|   0.213|  73.35|    8.19|   81.54|   7.205|  88.745|
|Claire     |     53|   2.313|  55.313|   2.202| 57.515|   2.016| 59.531|   3.347| 62.878|   1.097| 63.975|   0.741| 64.716|  11.932|  76.648|    1.69|  78.338|
|Oscar      |     27|   0.165|  27.165|   0.194|  27.36|   1.194| 28.554|       0| 28.554| -28.554|       |        |       |        |        |        |        |
|Declan     |     22|   1.487|  23.487|   0.566| 24.053|       2| 26.053| -26.053|       |        |       |        |       |        |        |        |        |
|Roisin     |     73|   2.974|  75.974|   1.117| 77.091|    5.33| 82.422|   6.541| 88.963|  12.097| 101.06|      -6|       |        |        |        |        |
|Elected    | Jasper|        |      Li|        |       |        |       |        |       |        | Roisin|        |       |        | Tilmann|        | Hillary|
|Eliminated |       |        |        |        |   Wang|        | Declan|        |  Oscar|        |       |        |  Julie|        |        |        |        |

Elected: Jasper, Li, Roisin, Tilmann, Hillary 


Results of Single transferable vote
===================================                            
Number of valid votes:   591
Number of invalid votes:  29
Number of candidates:     10
Number of seats:           5


|           |      1| 2-trans|       2| 3-trans|      3| 4-trans|      4| 5-trans|      5| 6-trans|      6| 7-trans|      7| 8-trans|       8| 9-trans|       9|
|:----------|------:|-------:|-------:|-------:|------:|-------:|------:|-------:|------:|-------:|------:|-------:|------:|-------:|-------:|-------:|-------:|
|Quota      | 98.501|        |  97.774|        | 97.438|        | 96.938|        | 95.351|        |  95.06|        | 94.684|        |  85.027|        |  83.542|
|Tilmann    |     73|   0.496|  73.496|   0.793| 74.289|   2.016| 76.305|   4.194|   80.5|   3.097| 83.597|   0.271| 83.868|  13.023|  96.891| -11.864|        |
|Julie      |     40|   1.652|  41.652|   2.137| 43.789|    6.33|  50.12|   2.347| 52.466|       6| 58.466|    3.65| 62.117| -62.117|        |        |        |
|Jasper     |    118| -19.499|        |        |       |        |       |        |       |        |       |        |       |        |        |        |        |
|Li         |    104|   4.296| 108.296| -10.523|       |        |       |        |       |        |       |        |       |        |        |        |        |
|Wang       |     20|   0.661|  20.661|   0.226| 20.887| -20.887|       |        |       |        |       |        |       |        |        |        |        |
|Hillary    |     61|   1.818|  62.818|   1.943| 64.761|       0| 64.761|   3.278| 68.039|   5.097| 73.137|   0.213|  73.35|    8.19|   81.54|   7.205|  88.745|
|Claire     |     53|   2.313|  55.313|   2.202| 57.515|   2.016| 59.531|   3.347| 62.878|   1.097| 63.975|   0.741| 64.716|  11.932|  76.648|    1.69|  78.338|
|Oscar      |     27|   0.165|  27.165|   0.194|  27.36|   1.194| 28.554|       0| 28.554| -28.554|       |        |       |        |        |        |        |
|Declan     |     22|   1.487|  23.487|   0.566| 24.053|       2| 26.053| -26.053|       |        |       |        |       |        |        |        |        |
|Roisin     |     73|   2.974|  75.974|   1.117| 77.091|    5.33| 82.422|   6.541| 88.963|  12.097| 101.06|      -6|       |        |        |        |        |
|Elected    | Jasper|        |      Li|        |       |        |       |        |       |        | Roisin|        |       |        | Tilmann|        | Hillary|
|Eliminated |       |        |        |        |   Wang|        | Declan|        |  Oscar|        |       |        |  Julie|        |        |        |        |

Elected: Jasper, Li, Roisin, Tilmann, Hillary 

    Tilmann Julie Jasper Li Wang Hillary Claire Oscar Declan Roisin
43        0     0      0  0    0       0      0     0      0      0
82        3     8      9  1    0       2      4     7     10      5
91        0     0      0  0    0       0      0     0      0      0
104       0     0      0  0    0       0      0     0      0      0
129       0     0      0  0    0       0      0     0      0      0
131       0     0      0  0    0       0      0     0      0      0
165       0     0      0  0    0       0      0     0      0      0
168       0     0      0  0    0       0      0     0      0      0
173       0     0      0  0    0       0      0     0      0      0
176       3     0      0  0    5       2      0     0      4      0
177       0     0      0  0    0       0      0     0      0      0
179       0     0      0  0    0       0      0     0      0      0
188       0     4      1  3    0       0      0     0      0      0
190       0     0      0  3    0       0      1     0      0      0
201       0     0      0  0    0       0      0     0      0      0
219       0     0      0  0    0       0      0     0      0      0
228       0     0      0  0    0       0      0     0      0      0
258       0     0      0  3    0       0      0     0      0      0
272       0     0      0  0    0       0      0     0      0      0
301       0     0      0  0    0       0      0     0      0      0
303       0     0      0  0    0       0      0     0      0      0
308       0     0      0  0    0       0      0     0      0      0
332       0     0      0  0    0       0      0     0      0      0
443       0     0      0  0    0       0      0     0      0      0
496       0     0      0  0    0       0      0     0      0      0
507       0     0      0  0    0       0      0     0      0      0
526       5     0      0  9    8       1      7     4      6     10
529       5     8      7  6    9       1      4    10      3      0
585       0     0      0  0    0       0      0     0      0      0

vote documentation built on May 2, 2019, 1:09 p.m.