district_winner_matrix {proporz} | R Documentation |
Find which party has the most votes in a district
Description
Create a logical matrix that shows whether a party got the most votes in a district or not.
Usage
district_winner_matrix(votes_matrix, district_seats = 1L)
Arguments
votes_matrix |
Vote count matrix with votes by party in rows and votes by district in columns. |
district_seats |
Vector defining the number of seats per district. Must be the same
length as |
Details
If two or more parties are tied and there are not enough seats for each tied party,
the matrix value is NA
.
Value
logical matrix with the same dimensions and names as votes_matrix
Examples
(vm = matrix(c(60,30,0,20,10,30), nrow = 3, dimnames = list(1:3, c("A", "B"))))
district_winner_matrix(vm)
# NA values if parties are tied (here in district B)
vm[1,2] <- 30
district_winner_matrix(vm)
# No NA values for tied parties if enough seats are available
district_winner_matrix(vm, c(1, 2))
[Package proporz version 1.5.1 Index]