roundp: Round Proportions

View source: R/roundp.R

roundpR Documentation

Round Proportions

Description

Round proportions so they sum to one (or allocate seats from election results).

Usage

roundp(x, digits = NULL, seats = NULL, method = "SL",
  labels = names(x))

Arguments

x

a vector containing proportions (or votes from an election).

digits

a number of decimals to use when rounding proportions, max 6.

seats

the number of seats to allocate from election results.

method

"DH", "MSL", or "SL" (default), indicating the algorithm to use.

labels

an optional vector of labels.

Value

Numeric vector of same length as x, with rounded proportions whose sum is 1 (or integers whose sum is seats).

Note

This function should be called either with a digits argument, or with a seats argument, not both.

The algorithms were designed to allocate seats from elections:

"DH" (D'Hondt) favors big parties - used in most of Europe and elsewhere
"MSL" (modified Sainte-Lague) favors big parties slightly - used in Norway and Sweden
"SL" (Sainte-Lague) does not favor big or small parties - used in New Zealand, Bosnia, and Latvia

arnima-github/arni documentation built on Oct. 28, 2023, 6:18 p.m.