allocation: Largest Remainder Method

View source: R/allocation.R

allocationR Documentation

Largest Remainder Method

Description

Largest Remainder Method

Usage

allocation(x, m, method, extra = NULL)

Arguments

x

a data.frame or tibble with two columns. The first and second column represents names of parties and numbers of votes, respectively.

m

a numeric value of district magnitude.

method

a character string giving a method for computing seat allocation. See "Allocation methods" section.

extra

a numeric vector of length m. If method is "custom divisor" ("cd") or "custom quota" ("cq"), this parameter is mandatory. See "About custom methods" section.

Value

A tibble object with two columns.

Allocation methods

  • Highest average method

    • "d'hondt" ("dt") or "jefferson": D'hondt / Jefferson method

    • "adams" or "cambridge": Adams / Cambridge method

    • "sainte-lague" ("sl") or "webster": Sainte-Laguë / Webster method

    • "modified sainte-lague" ("msl"): Modified Sainte-Laguë method

    • "danish": Danish method

    • "imperiali": Imperiali method

    • "hungtington-hill" ("hh"): Huntington-Hill method

    • "dean": Dean method

    • "ad": alpha-divergence. extra is mandatory.

    • "custom divisor" ("cd"): Custom divisor. extra is mandatory.

  • Largest reminder method

    • "hare-niemeyer" ("hn" or "hare"): Hare-Niemeyer quota

    • "droop": Droop quota

    • "hagenbach-bischoff" ("hb"): Hagenbach-Bischoff quota

    • "imperiali quota" ("iq"): Imperiali quota

    • "custom quota" ("cq"): Custom quota. extra is mandatory.

Examples

sample_data <- data.frame(Party = c("Party A", "Party B", "Party C", "Party D"),
                          Votes = c(53000, 25000, 16600, 5400))

sample_data

# Magnitude = 10, Hare-Niemeyer quota
allocation(x = sample_data, m = 10, method = "hare")

# Magnitude = 10, D'hondt method
allocation(x = sample_data, m = 10, method = "dt")

# Custom divisor: 1.4, 3, 5, 7, ... (identical to Modified Sainte-Laguë method)
allocation(x = sample_data, m = 10, method = "custom divisor",
           extra = c(1.4, seq(3, 19, by = 2)))

JaehyunSong/PRcalc documentation built on April 17, 2024, 1:23 p.m.