From fbcb459851d12f3485a5da5f71437353ccf343bc Mon Sep 17 00:00:00 2001 From: polettif Date: Thu, 4 Apr 2024 10:55:27 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20polettif?= =?UTF-8?q?/proporz@16eb90767d9c2f424b5c58a990cd0ab0aaa79e67=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 404.html | 2 +- LICENSE-text.html | 2 +- apple-touch-icon-120x120.png | Bin 13705 -> 13705 bytes apple-touch-icon-152x152.png | Bin 18680 -> 18680 bytes apple-touch-icon-180x180.png | Bin 23246 -> 23246 bytes apple-touch-icon-60x60.png | Bin 5483 -> 5483 bytes apple-touch-icon-76x76.png | Bin 7411 -> 7411 bytes apple-touch-icon.png | Bin 23246 -> 23246 bytes articles/apportionment_scenarios.html | 6 +- articles/index.html | 2 +- authors.html | 6 +- favicon-16x16.png | Bin 1334 -> 1334 bytes favicon-32x32.png | Bin 2507 -> 2507 bytes index.html | 65 +++++------ news/index.html | 10 +- pkgdown.yml | 2 +- reference/biproporz.html | 19 +++- reference/ceil_at.html | 12 +- reference/divide_votes_matrix.html | 113 +++++++++++++++++++ reference/divisor_methods.html | 2 +- reference/find_divisor.html | 124 +++++++++++++++++++++ reference/find_matrix_divisors.html | 119 ++++++++++++++++++++ reference/finland2019.html | 2 +- reference/get_divisors.html | 8 +- reference/highest_averages_method.html | 2 +- reference/index.html | 2 +- reference/largest_remainder_method.html | 2 +- reference/lower_apportionment.html | 60 ++++++++-- reference/pivot_to_matrix.html | 2 +- reference/proporz.html | 2 +- reference/proporz_methods.html | 2 +- reference/pukelsheim.html | 13 ++- reference/quorum_functions.html | 2 +- reference/reached_quorum_any_district.html | 2 +- reference/reached_quorum_total.html | 2 +- reference/reached_quorums.html | 2 +- reference/run_app.html | 2 +- reference/upper_apportionment.html | 5 +- reference/uri2020.html | 2 +- reference/weight_list_votes.html | 6 +- reference/zug2018.html | 2 +- sitemap.xml | 9 ++ 42 files changed, 518 insertions(+), 95 deletions(-) create mode 100644 reference/divide_votes_matrix.html create mode 100644 reference/find_divisor.html create mode 100644 reference/find_matrix_divisors.html diff --git a/404.html b/404.html index 48a9c6f..18e563b 100644 --- a/404.html +++ b/404.html @@ -39,7 +39,7 @@ proporz - 1.4.0 + 1.4.0.9000 diff --git a/LICENSE-text.html b/LICENSE-text.html index e308ea6..7c316e9 100644 --- a/LICENSE-text.html +++ b/LICENSE-text.html @@ -17,7 +17,7 @@ proporz - 1.4.0 + 1.4.0.9000 diff --git a/apple-touch-icon-120x120.png b/apple-touch-icon-120x120.png index 7491b9658550b67754cc432ae4660194123c547b..46befec6afd689171a3a1b373861b98f048915d1 100644 GIT binary patch delta 97 zcmeCo?#!N0$;raPWzJ@CsfmAMQ-FzwiLQZ3h@pX%si~ELnYMv}m4N}vQTDqG3=FCz jt`Q|Ei6yC4x%nxXX_X8{21X#&m>NoF>`$C5WttBFG&LIp delta 97 zcmeCo?#!N0$;r$j$f~o(t6y_tQ-Fzwv95thh@rWafvJ^=iMD}(m4QJZmt{Ny1A}Ub kYeY#(Vo9o1ZhlH;S|x*#fsu)>0TvAk;f;?cOPS^a01l5D3jhEB diff --git a/apple-touch-icon-152x152.png b/apple-touch-icon-152x152.png index bc7d6afc3fd4ec137762c61d8a70ddd83c63ef5d..da7bcabf34223b87d087f365e0fcd3747ae26be3 100644 GIT binary patch delta 99 zcmew{k@3ew#tD_2EG%5+?EY6b&D_|u-`&GR*T5vi(7?*n)XKnI+rYrez+llPo=gS? m2GtVRh?11Vl2ohQ{FKbJN(LhXBamuL4VT|5&fr-Ig8@ diff --git a/apple-touch-icon-180x180.png b/apple-touch-icon-180x180.png index cae860937adf22e5d83ccf3fd4d766ef0703db5f..31085235c645977e966d23c237b7673e32eb2b15 100644 GIT binary patch delta 78 zcmX@NmGRtG#tD_2EG%5+9QU) PHn~Ua>pUj^5y=MtjBXbn delta 76 zcmaE@^;&B}B_}hBAgh+Erk2dcCLzm7AZEnO4bQWMBkRjj6$ delta 97 zcmext`Pp(pB_}hBAgi{Ko>bSyrd`q=#<~V3A%^Bw2Buaf#@Yr3Rt5%B*0Nt@U|>)! kag8WRNi0dV%FR#7OsixtGB7gHHNc|b>4*KflUro+0b@ZNyZ`_I diff --git a/apple-touch-icon.png b/apple-touch-icon.png index 8761d9c8e1887295903a2d4b00c1c32ef5e4ca3e..3f67964a0de54b63df40125ac910d29543b6315e 100644 GIT binary patch delta 78 zcmX@NmGRtG#tD_2EG%5+oGWtY&)e8EHB#I}*T5vi(7?*n)XKn8+rYrez~EDFxyfX` RC@E}m%@@vhOpcGr2LRv>7@hzC delta 78 zcmX@NmGRtG#tD_2%q)Ve20Oejr)_MS8Yyn9YhV&$Xl`X-YGq=fZD3$!U@&b}u=ZrV RC@E}m&%eK(J~=)r9{|w77}Wp( diff --git a/articles/apportionment_scenarios.html b/articles/apportionment_scenarios.html index 41fe1a6..a31fbde 100644 --- a/articles/apportionment_scenarios.html +++ b/articles/apportionment_scenarios.html @@ -40,7 +40,7 @@ proporz - 1.4.0 + 1.4.0.9000 @@ -458,7 +458,7 @@

3.3) Alternative methods) # sort table by D'Hondt seats -df_bydistrict <- df_bydistrict[order(df_bydistrict[[1]], decreasing = T),] +df_bydistrict <- df_bydistrict[order(df_bydistrict[[1]], decreasing = TRUE),] # print parties with at least one seat knitr::kable(df_bydistrict[rowSums(df_bydistrict) > 0,]) @@ -1087,7 +1087,7 @@

4.2) Distribute seats among di
 full_biproportional = biproporz(votes_matrix, 
                                 district_seats = sum(district_seats),
-                                use_list_votes = F)
+                                use_list_votes = FALSE)
 
 # party seat distribution has not changed
 rowSums(full_biproportional) - rowSums(seats_biproportional)
diff --git a/articles/index.html b/articles/index.html
index 45b6ae5..a66c11f 100644
--- a/articles/index.html
+++ b/articles/index.html
@@ -17,7 +17,7 @@
       
       
         proporz
-        1.4.0
+        1.4.0.9000
       
     
diff --git a/authors.html b/authors.html index 71f454b..affffa3 100644 --- a/authors.html +++ b/authors.html @@ -17,7 +17,7 @@ proporz - 1.4.0 + 1.4.0.9000 @@ -73,13 +73,13 @@

Citation

Poletti F (2024). proporz: Proportional Apportionment. -R package version 1.4.0, https://github.com/polettif/proporz. +R package version 1.4.0.9000, https://github.com/polettif/proporz.

@Manual{,
   title = {proporz: Proportional Apportionment},
   author = {Flavio Poletti},
   year = {2024},
-  note = {R package version 1.4.0},
+  note = {R package version 1.4.0.9000},
   url = {https://github.com/polettif/proporz},
 }
diff --git a/favicon-16x16.png b/favicon-16x16.png index 7684d562aebe2f6b9b3d7cdc22f5c4be52aca2b8..b89df858f25929187c1c7e870e82cc244b41af3f 100644 GIT binary patch delta 99 zcmdnSwT)|o6Ei0Z3zs?XdWPus&ECu=j2cfmCB^c+E8-V)Aj8d;s?v8hii% delta 99 zcmdnSwT)|o6Ei0>iy*7%2}Sjno4uJ$7(I-24NO7|&8-YftxS!z4GgRd3?kUs{TUb- mR7+eVN>UO_Qmu0HQ!>*k8H@~!Omq#fXwZz>|9SFpmV5xx*cti& diff --git a/favicon-32x32.png b/favicon-32x32.png index befcf3ae42e695ad331dd66114b7ec1f0a888f57..ddd41a503fe7d7ed1e7aeb97e4a8c11acd5c813e 100644 GIT binary patch delta 76 zcmX>td|G%yB_|6DmpPvqCztKUrb!&)Cb|YDA%+H4rlwYgCfWuDRt5&~AH=dIYja9r Olha$f?%L!S&U^sgTod5{ delta 76 zcmX>td|G%yB_}hBAgj5WzT44_O_Mmpjdcx7LJZBV3{0&|O|=aStPBjSuN#$4*5;JL OCg;`Fb#ihHXFdQ9ycBi- diff --git a/index.html b/index.html index 190e67e..b7f9170 100644 --- a/index.html +++ b/index.html @@ -45,7 +45,7 @@ proporz - 1.4.0 + 1.4.0.9000 @@ -146,45 +146,35 @@

Proportional ApportionmentBiproportional Apportionment

Biproportional apportionment (Wikipedia) is a method to proportionally allocate seats among parties and districts.

-

We can use the provided zug2018 data set to illustrate biproportional apportionment with biproporz(). You need a ‘votes matrix’ as input which shows the number of votes for each party (rows) and district (columns). In this data set, parties are called ‘lists’ and districts ‘entities’.

+

We can use the provided uri2020 data set to illustrate biproportional apportionment with biproporz(). You need a ‘votes matrix’ as input which shows the number of votes for each party (rows) and district (columns). You also need to define the number of seats per district.

-votes_df = unique(zug2018[c("list_id", "entity_id", "list_votes")])
-votes_matrix = pivot_to_matrix(votes_df)
-votes_matrix
-#>        entity_id
-#> list_id  1701 1702 1703 1704 1705 1706 1707 1708 1709 1710  1711
-#>       1  2993    0    0    0    0    0    0    0    0    0     0
-#>       2  8108 4687 1584  531  279  477 2363 3860 1481   91 22023
-#>       3 19389 9334 4807 1946  396 2844 3523 4702 3310  812 21343
-#>       4 14814 6691 4005  826  379 1654 2842 2624 2713  461 33789
-#>       5  4486 2270  621  198    0  361  728  465  925    0 10131
-#>       6 15695 4705 1750   84    0   51  627 1106 1563  302 21794
-#>       7 21298 8178 2875 1336  399 1450 3715 2610 4063  344 26798
+(votes_matrix <- uri2020$votes_matrix)
+#>      Altdorf Bürglen Erstfeld Schattdorf
+#> CVP    11471    2822     2309       4794
+#> SPGB   11908    1606     1705       2600
+#> FDP     9213    1567      946       2961
+#> SVP     7756    2945     1573       3498
 
-distr_df = unique(zug2018[c("entity_id", "election_mandates")])
-district_seats = setNames(distr_df$election_mandates, distr_df$entity_id)
-district_seats
-#> 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 
-#>   15   10    6    3    2    4    7    6    6    2   19
+(district_seats <- uri2020$seats_vector) +#> Altdorf Bürglen Erstfeld Schattdorf +#> 15 7 6 9 + +biproporz(votes_matrix, district_seats) +#> Altdorf Bürglen Erstfeld Schattdorf +#> CVP 5 2 2 3 +#> SPGB 4 1 2 2 +#> FDP 3 1 1 2 +#> SVP 3 3 1 2 +

You can use pukelsheim() for dataframes in long format as input data. It is a wrapper for biproporz(). zug2018 shows an actual election result for the Canton of Zug in a dataframe. We use this data set to create input data for pukelsheim(). The other parameters are set to reflect the actual election system.

-biproporz(votes_matrix, district_seats, quorum_any(any_district = 0.05, total = 0.03))
-#>        entity_id
-#> list_id 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711
-#>       1    0    0    0    0    0    0    0    0    0    0    0
-#>       2    2    1    1    0    0    0    1    2    1    0    3
-#>       3    3    3    2    1    1    2    2    2    1    1    3
-#>       4    2    2    1    1    0    1    2    1    1    1    5
-#>       5    1    1    0    0    0    0    0    0    0    0    2
-#>       6    3    1    1    0    0    0    0    0    1    0    3
-#>       7    4    2    1    1    1    1    2    1    2    0    3
-

You can use pukelsheim() for data.frames in long format as input data. It is a wrapper for biproporz().

-
-votes_df = unique(zug2018[c("list_id", "entity_id", "list_votes")])
+# In this data set, parties are called 'lists' and districts 'entities'.
+votes_df = unique(zug2018[c("list_id", "entity_id", "list_votes")])
 district_seats_df = unique(zug2018[c("entity_id", "election_mandates")])
 
 seats_df = pukelsheim(votes_df,
                       district_seats_df,
-                      quorum = quorum_any(any_district = 0.05, total = 0.03))
+                      quorum = quorum_any(any_district = 0.05, total = 0.03),
+                      winner_take_one = TRUE)
 
 head(seats_df)
 #>   list_id entity_id list_votes seats
@@ -201,11 +191,10 @@ 

Biproportional ApportionmentShiny app

The package provides a basic Shiny app where you can calculate biproportional apportionment on an interactive dashboard. You need to have the packages shiny and shinyMatrix installed.

-
+
 # install.packages("shiny")
 # install.packages("shinyMatrix")
-library(proporz)
-run_app()
+proporz::run_app()

@@ -216,7 +205,7 @@

Function detailsDivisor methods

You can use divisor methods directly:

-
+
 votes = c("Party A" = 690, "Party B" = 370, "Party C" = 210, "Party D" = 10)
 
 # D'Hondt, Jefferson or Hagenbach-Bischoff method
@@ -248,7 +237,7 @@ 

Divisor methodsLargest remainder method

The largest remainder method is also accessible directly:

-
+
 votes = c("I" = 16200, "II" = 47000, "III" = 12700)
 
 # Hamilton, Hare-Niemeyer or Vinton method
diff --git a/news/index.html b/news/index.html
index 1130ba5..58757aa 100644
--- a/news/index.html
+++ b/news/index.html
@@ -17,7 +17,7 @@
       
       
         proporz
-        1.4.0
+        1.4.0.9000
       
     
@@ -57,6 +57,14 @@

Changelog

Source: NEWS.md
+
+ +
  • add new feature: winner take one method for biproporz() and pukelsheim (#10)
  • +
  • allow non-integer vote counts
  • +
  • round divisors to as few digits as possible
  • +
  • changed error message for undefined/tied results
  • +
  • fixed bugs and added more real data tests
  • +
  • first CRAN release
  • diff --git a/pkgdown.yml b/pkgdown.yml index 3da834a..4fd2973 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -3,5 +3,5 @@ pkgdown: 2.0.7 pkgdown_sha: ~ articles: apportionment_scenarios: apportionment_scenarios.html -last_built: 2024-03-04T17:05Z +last_built: 2024-04-04T10:55Z diff --git a/reference/biproporz.html b/reference/biproporz.html index d98d504..a6df6dd 100644 --- a/reference/biproporz.html +++ b/reference/biproporz.html @@ -18,7 +18,7 @@ proporz - 1.4.0 + 1.4.0.9000
@@ -106,11 +106,18 @@

Arguments

method
-

Defines the method how seats in upper and lower apportionment are assigned. -For a different method for upper and lower apportionment use a vector with two entries. -The default "round" for the Sainte-Laguë/Webster method is the standard for -biproportional apportionment and the only method guaranteed to terminate. See -proporz() for other methods.

+

Defines which method is used to assign seats. The following methods are +recommended:

  • round: Uses the Sainte-Laguë/Webster method (rounding half up) for the upper +and lower apportionment which is the standard for biproportional apportionment and +the only method guaranteed to terminate.

  • +
  • wto: "winner take one" works like "round" with a condition that the party that +got the most votes in a district must get at least one seat ('Majorzbedingung') +in said district. Seats in the upper apportionment are assigned with +Sainte-Laguë/Webster. votes_matrix must have row and column names to use this +method. See lower_apportionment() for more details.

  • +

It is also possible to use any divisor method name listed in proporz(). If you want to +use a different method for the upper and lower apportionment, provide a list with two +entries.

diff --git a/reference/ceil_at.html b/reference/ceil_at.html index 811ef34..a5a10a7 100644 --- a/reference/ceil_at.html +++ b/reference/ceil_at.html @@ -1,5 +1,6 @@ -Rounding with predefined thresholds — ceil_at • proporzRounding with predefined thresholds — ceil_at • proporz @@ -17,7 +18,7 @@ proporz - 1.4.0 + 1.4.0.9000
@@ -59,7 +60,8 @@

Rounding with predefined thresholds

-

Round x up if x-floor(x) >= threshold, otherwise round down.

+

Round x up to ceiling(x) if x-floor(x) >= threshold, +otherwise round down to floor(x).

@@ -69,7 +71,7 @@

Rounding with predefined thresholds

Arguments

x
-

numeric vector >= 0 (NaN is not supported)

+

numeric vector or matrix >= 0 (NaN is not supported)

threshold
@@ -81,7 +83,7 @@

Arguments

Value

-

the rounded vector

+

the rounded vector or matrix

diff --git a/reference/divide_votes_matrix.html b/reference/divide_votes_matrix.html new file mode 100644 index 0000000..c348f80 --- /dev/null +++ b/reference/divide_votes_matrix.html @@ -0,0 +1,113 @@ + +Calculate raw seat matrix — divide_votes_matrix • proporz + + +
+
+ + + +
+
+ + +
+

Apply row and column divisors to matrix to get non-rounded seat values.

+
+ +
+
divide_votes_matrix(M, col_divisors, row_divisors)
+
+ +
+

Arguments

+
M
+

matrix

+ + +
col_divisors
+

divisors to apply to columns

+ + +
row_divisors
+

divisors to apply to rows

+ +
+
+

Value

+ + +

matrix with the same dimension as M containing non-rounded seat values

+
+ +
+ +
+ + +
+ +
+

Site built with pkgdown 2.0.7.

+
+ +
+ + + + + + + + diff --git a/reference/divisor_methods.html b/reference/divisor_methods.html index a56c5f6..3942e72 100644 --- a/reference/divisor_methods.html +++ b/reference/divisor_methods.html @@ -18,7 +18,7 @@ proporz - 1.4.0 + 1.4.0.9000
diff --git a/reference/find_divisor.html b/reference/find_divisor.html new file mode 100644 index 0000000..9b0bb60 --- /dev/null +++ b/reference/find_divisor.html @@ -0,0 +1,124 @@ + +Find divisor to assign seats — find_divisor • proporz + + +
+
+ + + +
+
+ + +
+

Find a divisor between divisor_from and divisor_to such as +sum(round_func(votes/divisor)) equals target_seats

+
+ +
+
find_divisor(votes, divisor_from, divisor_to, target_seats, round_func)
+
+ +
+

Arguments

+
votes
+

votes (matrix with only one column or vector, allows to use row/colnames +within round_func)

+ + +
divisor_from
+

lower bound for divisor search range (is decreased if necessary)

+ + +
divisor_to
+

upper bound for divisor search range (is increased if necessary)

+ + +
target_seats
+

number of seats to distribute (single number)

+ + +
round_func
+

rounding function

+ +
+
+

Value

+ + +

divisor

+
+ +
+ +
+ + +
+ +
+

Site built with pkgdown 2.0.7.

+
+ +
+ + + + + + + + diff --git a/reference/find_matrix_divisors.html b/reference/find_matrix_divisors.html new file mode 100644 index 0000000..c74b8ac --- /dev/null +++ b/reference/find_matrix_divisors.html @@ -0,0 +1,119 @@ + +Find divisors for a matrix with alternate scaling — find_matrix_divisors • proporz + + +
+
+ + + +
+
+ + +
+

Find divisors for a matrix with alternate scaling

+
+ +
+
find_matrix_divisors(M, seats_cols, seats_rows, round_func)
+
+ +
+

Arguments

+
M
+

votes_matrix

+ + +
seats_cols
+

target seats for each column

+ + +
seats_rows
+

target seats for each row

+ + +
round_func
+

rounding function. Called like +round_func(M/row_divisors/col_divisors), divisors are applied row/col-wise with +divide_votes_matrix().

+ +
+
+

Value

+ + +

list of divisors (column and row)

+
+ +
+ +
+ + +
+ +
+

Site built with pkgdown 2.0.7.

+
+ +
+ + + + + + + + diff --git a/reference/finland2019.html b/reference/finland2019.html index d145254..0e72ce9 100644 --- a/reference/finland2019.html +++ b/reference/finland2019.html @@ -18,7 +18,7 @@ proporz - 1.4.0 + 1.4.0.9000
diff --git a/reference/get_divisors.html b/reference/get_divisors.html index d1d2e90..e3427b2 100644 --- a/reference/get_divisors.html +++ b/reference/get_divisors.html @@ -19,7 +19,7 @@ proporz - 1.4.0 + 1.4.0.9000
@@ -56,7 +56,7 @@
@@ -90,11 +90,11 @@

Examples

get_divisors(seats_matrix) #> $districts #> Altdorf Bürglen Erstfeld Schattdorf -#> 2690.000 1193.875 1089.000 1539.000 +#> 2690 1194 1089 1539 #> #> $parties #> CVP SPGB FDP SVP -#> 0.946 1.000 1.000 0.969 +#> 0.946 1.000 1.000 0.970 #>
diff --git a/reference/highest_averages_method.html b/reference/highest_averages_method.html index 583a258..3c05399 100644 --- a/reference/highest_averages_method.html +++ b/reference/highest_averages_method.html @@ -17,7 +17,7 @@ proporz - 1.4.0 + 1.4.0.9000 diff --git a/reference/index.html b/reference/index.html index 149f299..f0f1b20 100644 --- a/reference/index.html +++ b/reference/index.html @@ -17,7 +17,7 @@ proporz - 1.4.0 + 1.4.0.9000 diff --git a/reference/largest_remainder_method.html b/reference/largest_remainder_method.html index 7502555..81cef93 100644 --- a/reference/largest_remainder_method.html +++ b/reference/largest_remainder_method.html @@ -18,7 +18,7 @@ proporz - 1.4.0 + 1.4.0.9000 diff --git a/reference/lower_apportionment.html b/reference/lower_apportionment.html index bbdf52f..08bb71c 100644 --- a/reference/lower_apportionment.html +++ b/reference/lower_apportionment.html @@ -18,7 +18,7 @@ proporz - 1.4.0 + 1.4.0.9000 @@ -71,7 +71,7 @@

Calculate lower apportionment

Arguments

votes_matrix
-

votes matrix

+

matrix with votes by party in rows and votes by district in columns.

seats_cols
@@ -85,10 +85,18 @@

Arguments

method
-

Apportion method that defines how seats are assigned. The default "round" -for the Sainte-Laguë/Webster method is the standard for biproportional apportionment -and the only method guaranteed to terminate. See proporz() for other methods. It is -also possible to provide a function that rounds a vector or matrix.

+

Apportion method that defines how seats are assigned. The +following methods are supported:

  • round: The default Sainte-Laguë/Webster method is the standard +for biproportional apportionment and the only method guaranteed to terminate.

  • +
  • wto: "winner take one" works like "round" with a condition that the party that +got the most votes in a district must get at least one seat ('Majorzbedingung'). +The condition does not apply in a district if two or more parties have the same +number of votes and there are not enough seats for these parties. A warning is +issued in this case. Modify the votes matrix to explicitly break ties.

  • +
  • You can provide a custom function that rounds a matrix (i.e. the +the votes_matrix divided by party and list divisors).

  • +
  • It is possible to use any divisor method name listed in proporz().

  • +
@@ -135,10 +143,46 @@

Examples

#> [3,] 2 1 1 #> attr(,"divisors") #> attr(,"divisors")$districts -#> [1] 207.81 180.25 161.50 +#> [1] 207 180 161 #> #> attr(,"divisors")$parties -#> [1] 1.16 1.01 1.00 +#> [1] 1.15 1.00 1.00 +#> + + +# using "winner take one" +vm = matrix(c(200,100,10,11), 2, + dimnames = list(c("Party A", "Party B"), c("I", "II"))) +district_seats = setNames(c(2,1), colnames(vm)) +ua = upper_apportionment(vm, district_seats) + +lower_apportionment(vm, ua$district, ua$party, method = "wto") +#> I II +#> Party A 2 0 +#> Party B 0 1 +#> attr(,"divisors") +#> attr(,"divisors")$districts +#> I II +#> 139 22 +#> +#> attr(,"divisors")$parties +#> Party A Party B +#> 0.92 2.00 +#> + +# compare to standard method +lower_apportionment(vm, ua$district, ua$party, method = "round") +#> I II +#> Party A 1 1 +#> Party B 1 0 +#> attr(,"divisors") +#> attr(,"divisors")$districts +#> I II +#> 150 21 +#> +#> attr(,"divisors")$parties +#> Party A Party B +#> 0.9 1.2 #>
diff --git a/reference/pivot_to_matrix.html b/reference/pivot_to_matrix.html index 22323a0..0a32e05 100644 --- a/reference/pivot_to_matrix.html +++ b/reference/pivot_to_matrix.html @@ -19,7 +19,7 @@ proporz - 1.4.0 + 1.4.0.9000 diff --git a/reference/proporz.html b/reference/proporz.html index 40499f7..1155a8d 100644 --- a/reference/proporz.html +++ b/reference/proporz.html @@ -17,7 +17,7 @@ proporz - 1.4.0 + 1.4.0.9000 diff --git a/reference/proporz_methods.html b/reference/proporz_methods.html index 38970ee..4dd9bec 100644 --- a/reference/proporz_methods.html +++ b/reference/proporz_methods.html @@ -18,7 +18,7 @@ proporz - 1.4.0 + 1.4.0.9000 diff --git a/reference/pukelsheim.html b/reference/pukelsheim.html index 16a8cd3..9782564 100644 --- a/reference/pukelsheim.html +++ b/reference/pukelsheim.html @@ -18,7 +18,7 @@ proporz - 1.4.0 + 1.4.0.9000 @@ -70,7 +70,8 @@

Biproportional apportionment with data frames

district_seats_df, quorum, new_seats_col = "seats", - use_list_votes = TRUE + use_list_votes = TRUE, + winner_take_one = FALSE )
@@ -106,6 +107,11 @@

Arguments

as many votes as there are seats in a district. Set to FALSE if votes_df shows the number of voters (e.g. they can only vote for one party).

+ +
winner_take_one
+

Set to TRUE if the party that got the most votes in a district +must get at least one seat ('Majorzbedingung') in this district. Default is FALSE.

+

Value

@@ -141,7 +147,8 @@

Examples

seats_df = pukelsheim(votes_df, district_seats_df, - quorum_any(any_district = 0.05, total = 0.03)) + quorum_any(any_district = 0.05, total = 0.03), + winner_take_one = TRUE) head(seats_df) #> list_id entity_id list_votes seats diff --git a/reference/quorum_functions.html b/reference/quorum_functions.html index 5764fc9..f598e92 100644 --- a/reference/quorum_functions.html +++ b/reference/quorum_functions.html @@ -19,7 +19,7 @@ proporz - 1.4.0 + 1.4.0.9000
diff --git a/reference/reached_quorum_any_district.html b/reference/reached_quorum_any_district.html index 6b26262..31087c3 100644 --- a/reference/reached_quorum_any_district.html +++ b/reference/reached_quorum_any_district.html @@ -17,7 +17,7 @@ proporz - 1.4.0 + 1.4.0.9000 diff --git a/reference/reached_quorum_total.html b/reference/reached_quorum_total.html index de7964d..d5b4713 100644 --- a/reference/reached_quorum_total.html +++ b/reference/reached_quorum_total.html @@ -17,7 +17,7 @@ proporz - 1.4.0 + 1.4.0.9000 diff --git a/reference/reached_quorums.html b/reference/reached_quorums.html index a7f6d8a..6c61141 100644 --- a/reference/reached_quorums.html +++ b/reference/reached_quorums.html @@ -17,7 +17,7 @@ proporz - 1.4.0 + 1.4.0.9000 diff --git a/reference/run_app.html b/reference/run_app.html index 6f67649..eb9114e 100644 --- a/reference/run_app.html +++ b/reference/run_app.html @@ -17,7 +17,7 @@ proporz - 1.4.0 + 1.4.0.9000 diff --git a/reference/upper_apportionment.html b/reference/upper_apportionment.html index 8aef4d3..6beb441 100644 --- a/reference/upper_apportionment.html +++ b/reference/upper_apportionment.html @@ -21,7 +21,7 @@ proporz - 1.4.0 + 1.4.0.9000 @@ -103,7 +103,8 @@

Arguments

method
-

Apportion method that defines how seats are assigned, see proporz().

+

Apportion method that defines how seats are assigned, see proporz(). Default +is the Saintë-Lague/Webster method.

diff --git a/reference/uri2020.html b/reference/uri2020.html index 679aad8..8a4636b 100644 --- a/reference/uri2020.html +++ b/reference/uri2020.html @@ -19,7 +19,7 @@ proporz - 1.4.0 + 1.4.0.9000
diff --git a/reference/weight_list_votes.html b/reference/weight_list_votes.html index 7431857..ed50fc2 100644 --- a/reference/weight_list_votes.html +++ b/reference/weight_list_votes.html @@ -1,7 +1,7 @@ Create weighted votes matrix — weight_list_votes • proporz @@ -19,7 +19,7 @@ proporz - 1.4.0 + 1.4.0.9000 @@ -63,7 +63,7 @@

Create weighted votes matrix

Weigh list votes by dividing the votes matrix entries by the number of seats per district. This method is used in upper_apportionment() if -use_list_votes is TRUE (default).

+use_list_votes is TRUE (default). The weighted votes are not rounded.

diff --git a/reference/zug2018.html b/reference/zug2018.html index 26595b5..133413a 100644 --- a/reference/zug2018.html +++ b/reference/zug2018.html @@ -18,7 +18,7 @@ proporz - 1.4.0 + 1.4.0.9000
diff --git a/sitemap.xml b/sitemap.xml index 092cc5b..bf6c9f4 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -27,9 +27,18 @@ /reference/ceil_at.html + + /reference/divide_votes_matrix.html + /reference/divisor_methods.html + + /reference/find_divisor.html + + + /reference/find_matrix_divisors.html + /reference/finland2019.html