Learn R Programming

ggparliament (version 0.1.2)

ggparliament: Parliament Plots

Description

Produce a Wikipedia-style hemicycle plot of parliamentary composition

Usage

ggparliament(data, party, seats1, seats2, style = c("dots", "arc", "bar",
  "pie", "rose"), label = c("name", "seats", "both", "neither"),
  portion = 0.75, nrows = 10, size = 2L, total = NULL, ...)

Arguments

data

A data frame

party

The name of a variable in data containing the names of parties. If data is missing, this can be a vector of party names.

seats1

The name of a variable in data containing the number of seats for each party. If data is missing, this can be a vector of seat counts.

seats2

Optionally, the name of a variable in data containing a second set of numbers of seats for each party. If data is missing, this can be a vector of seat counts. This can be useful for showing, e.g., pre-/post-election changes in numbers of seats.

style

A character string specifying the style of the graph. Either “arc” or “dots”.

label

A character string specifying the type of label to place next to each party group.

portion

A numeric value specifying what proportion of a full circle should be used for drawing the plot.

nrows

If style = "dots", a numeric value indicating how many rows to use.

size

A numeric value specifying the size of dots if style = "dots".

total

A numeric value indicating the font size of a text label indicating the number of seats in the parliament. If NULL (the default), this is omitted.

Ignored

Value

A ggplot object.

Details

This transforms a data frame of party seat counts into ggplot scatterplot using coord_polar.

References

http://stackoverflow.com/questions/42729174/creating-a-half-donut-or-parliamentary-seating-chart

Examples

Run this code
# NOT RUN {
d <- data.frame(Party = c("GUE/NGL", "S&D", "Greens/EFA",
                          "ALDE", "EPP", "ECR", "EFD", "NA"),
                Number = c(35, 184, 55, 84, 265, 54, 32, 27),
                NumberPre = c(20, 166, 90, 40, 210, 130, 60, 20))

# dot-type
ggparliament(d, party = Party, seats1 = Number)

# arc-type
ggparliament(d, party = Party, seats1 = Number, style = "arc")

# arc-type with pre/post changes
ggparliament(d, party = Party, seats1 = Number, seats2 = NumberPre, style = "arc")

# }

Run the code above in your browser using DataLab