zmeers / ggparliament

Simple parliament plots using ggplot2
https://zmeers.github.io/ggparliament/
Other
150 stars 13 forks source link

Will parliament_data work for long data sets? #24

Closed zmeers closed 6 years ago

zmeers commented 6 years ago

Hmm, I'm curious to see if this will work. Say someone has a long list of every MP in parliament with their party affiliation, i.e. column 1 is name and column 2 is party.... Can we still use parliament_data() to find the x and y coordinates, providing they specify the row numbers and type? It might be something to look into and in theory should be easy to implement (famous last words, right?!) as the data doesn't need to expand, we just need to map the x and y coordinates to each parliamentarian. Provided the user writes seats = NULL, or even seats = "long_format" in parliament_data(), we could then say if (object$seats == NULL / "long_format") { calc_coordinates ... } .

For example...

data <- data.frame(
name <- c(...),
party <- c(...)
)
seats <- parliament_data(type = 'semicircle', 
parl_rows = 8, 
seats = "long_format", 
election_data = data)

This should spit out the same data frame plus x, y, row, theta -- basically everything we get from calc_coordinates anyway. The user can then add whatever additional data they want, like colours, gender, etc.