as_prcalc | R Documentation |
.csv
or data.frame
(tibble
) to prcalc
object.Transformation from .csv
or data.frame
(tibble
) to prcalc
object.
as_prcalc(x, l1, l2 = NULL, p, q = NULL, type = c("nested", "span"), ...)
read_prcalc(x, l1, l2 = NULL, p, q = NULL, type = c("nested", "span"), ...)
x |
a path of |
l1 |
a character. Mandatory. A column name of level 1 (region or state). |
l2 |
a character. Optional. A column name of level 2 (party or district). |
p |
a character. Mandatory. A column name of population or number of electorates. |
q |
a character. Optional. A column name of magnitude or number of allocated seats. If |
type |
a type of |
... |
ignored |
At least two columns of x
are required—l1
and p
.
a prcalc
object.
data("jp_lower_2021_result")
as_prcalc(jp_lower_2021_result,
l1 = "Pref",
l2 = "Party",
p = "Votes",
q = "Seats",
type = "span")
data("br_district_2010")
# Brazil has single block PR system, l2 can be omitted.
# If type = "party", raw names of districts are preserved.
br_district_2010 |>
as_prcalc(l1 = "district",
p = "population",
q = "magnitude",
type = "span")
data("au_district_2010")
# Because all of magnitude are 1 and type of l2 is district,
# you can omit q and type arguments.
as_prcalc(au_district_2010,
l1 = "region",
l2 = "district",
p = "electorates")
# You can import .csv format and transform into prcalc object directly.
## Not run:
read_prcalc("data/my_file.csv",
l1 = "region",
l2 = "district",
p = "electorates",
q = "magnitude",
type = "nested")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.