| Title: | Interface to Swiss Parliament Web Services and the 'OpenParlData' API |
|---|---|
| Description: | Provides machine-readable access to parliamentary data of the Swiss Federal Assembly via the 'OData' interface (<https://ws.parlament.ch/odata.svc/>) and the 'OpenParlData' REST API (<https://api.openparldata.ch>), which also offers harmonized data for selected cantonal and municipal parliaments. |
| Authors: | David Zumbach [aut, cre], Benjamin Gföhler [ctb] |
| Maintainer: | David Zumbach <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.0 |
| Built: | 2026-06-08 07:51:03 UTC |
| Source: | https://github.com/zumbov2/swissparl |
clean_text removes HTML code, brackets and their contents as well as line breaks from texts.
clean_text(text, keep_round_brackets = T)clean_text(text, keep_round_brackets = T)
text |
a character vector. |
keep_round_brackets |
if |
A character vector of same length as text.
## Not run: # Get clean version of transcripts get_glimpse(table = "Transcript", rows = 1000, Language = "DE") %>% mutate(Text2 = clean_text(Text)) ## End(Not run)## Not run: # Get clean version of transcripts get_glimpse(table = "Transcript", rows = 1000, Language = "DE") %>% mutate(Text2 = clean_text(Text)) ## End(Not run)
get_data retrieves data from the WebServices of the Swiss Parliament.
get_data( table, package_size = 1000, stop = T, attempts = 10, wtf = 1, silent = F, ... )get_data( table, package_size = 1000, stop = T, attempts = 10, wtf = 1, silent = F, ... )
table |
name of the table to download. For an overview of available tables use |
package_size |
number of rows to download at once (maximum = 1000). If a query exceeds |
stop |
if |
attempts |
maximum number of repetitions of a single subquery if it was not successful. |
wtf |
factor for extending the waiting time after unsuccessful queries. If |
silent |
if |
... |
optional filter arguments with values. Since all entries are available in several languages, it is
recommended to filter the calls by language., e.g.
|
A tibble of different length and variable composition.
## Not run: # Retrieve data on the members of the Swiss Parliament get_data(table = "Person", Language = "DE") # Retrieve voting behavior of selected councillors get_data( table = "Voting", PersonNumber = c(21, 4167), Language = "DE" ) # Retrieve businesses submitted during a specified period get_data( table = "Business", SubmissionDate = c(">2018-12-31", "<2019-02-01"), Language = "DE" ) # Retrieve businesses on the subject of CO2 get_data( table = "Business", Title = "~CO2", Language = "DE" ) ## End(Not run)## Not run: # Retrieve data on the members of the Swiss Parliament get_data(table = "Person", Language = "DE") # Retrieve voting behavior of selected councillors get_data( table = "Voting", PersonNumber = c(21, 4167), Language = "DE" ) # Retrieve businesses submitted during a specified period get_data( table = "Business", SubmissionDate = c(">2018-12-31", "<2019-02-01"), Language = "DE" ) # Retrieve businesses on the subject of CO2 get_data( table = "Business", Title = "~CO2", Language = "DE" ) ## End(Not run)
get_data2 retrieves data from the OpenParlData.ch REST API for a
given resource.
get_data2(table, max_rows, package_size = 1000, silent = FALSE, ...)get_data2(table, max_rows, package_size = 1000, silent = FALSE, ...)
table |
name of the OpenParlData resource to download. For an overview of available
endpoints use |
max_rows |
maximum number of rows to return. If omitted, all available rows matching the query are downloaded. |
package_size |
number of rows to download per request (mapped to
the API parameter |
silent |
if |
... |
additional query parameters passed to the OpenParlData endpoint as URL query parameters. Common parameters include:
Resource-specific filters (e.g. |
A tibble containing up to max_rows records. Column composition
depends on the selected resource and query parameters.
## Not run: # Retrieve first 10 persons get_data2("persons", max_rows = 10) # Retrieve a specific person by first and last name get_data2( "persons", firstname = "Karin", lastname = "Keller-Sutter" ) # Partial search (default mode) in affairs get_data2("affairs", max_rows = 10, search = "Budget", search_mode = "partial") # Boolean search with grouping (note: '&' is an operator in boolean mode) get_data2( "affairs", max_rows = 10, search = "(Klima | Umwelt) & Schweiz", search_mode = "boolean" ) # Combine search with scope/language and sorting get_data2( "affairs", max_rows = 10, search = "Bundesrat Parlament", search_mode = "natural", search_language = "de", sort_by = "-begin_date" ) ## End(Not run)## Not run: # Retrieve first 10 persons get_data2("persons", max_rows = 10) # Retrieve a specific person by first and last name get_data2( "persons", firstname = "Karin", lastname = "Keller-Sutter" ) # Partial search (default mode) in affairs get_data2("affairs", max_rows = 10, search = "Budget", search_mode = "partial") # Boolean search with grouping (note: '&' is an operator in boolean mode) get_data2( "affairs", max_rows = 10, search = "(Klima | Umwelt) & Schweiz", search_mode = "boolean" ) # Combine search with scope/language and sorting get_data2( "affairs", max_rows = 10, search = "Bundesrat Parlament", search_mode = "natural", search_language = "de", sort_by = "-begin_date" ) ## End(Not run)
get_glimpse retrieves the first rows of a table of the Swiss Parliament WebServices and
allows a first insight into its data structure.
get_glimpse(table, rows = 20, Language = "DE")get_glimpse(table, rows = 20, Language = "DE")
table |
name of the table to glimpse into. For an overview of available tables use |
rows |
number of records to download. Maximum is 1000. |
Language |
filter rows by language. Possible are |
A tibble of different length and variable composition.
## Not run: # Short excerpt of table "Person" get_glimpse(table = "Person") ## End(Not run)## Not run: # Short excerpt of table "Person" get_glimpse(table = "Person") ## End(Not run)
get_glimpse2 retrieves the first rows of a resource provided by the
OpenParlData.ch REST API and allows a first insight into its data structure.
get_glimpse2(table, rows = 20)get_glimpse2(table, rows = 20)
table |
name of the OpenParlData resource to glimpse
into. For an overview of available endpoints use
|
rows |
number of records to download. Maximum is 1000. |
A tibble containing up to rows records. Column composition
depends on the selected OpenParlData resource.
## Not run: # Short excerpt of OpenParlData resource "persons" get_glimpse2(table = "persons") ## End(Not run)## Not run: # Short excerpt of OpenParlData resource "persons" get_glimpse2(table = "persons") ## End(Not run)
get_overview retrieves the names of all available tables of the Swiss Parliament WebServices and
the variables they contain.
get_overview(silent = F)get_overview(silent = F)
silent |
if |
A tibble with the 2 columns table and variable.
## Not run: get_overview() ## End(Not run)## Not run: get_overview() ## End(Not run)
get_overview2 retrieves the names of the main resources provided by
the OpenParlData.ch REST API and the fields they contain.
get_overview2(silent = F)get_overview2(silent = F)
silent |
if |
A tibble with the 2 columns table and variable.
## Not run: # Overview for OpenParlData REST API get_overview2() ## End(Not run)## Not run: # Overview for OpenParlData REST API get_overview2() ## End(Not run)
get_tables retrieves the names of the available tables of the Swiss Parliament WebServices.
get_tables()get_tables()
A sorted character vector containing the names of the available tables.
## Not run: # Get all available tables get_tables() ## End(Not run)## Not run: # Get all available tables get_tables() ## End(Not run)
get_tables2 retrieves the names of the main REST API endpoints
provided by the OpenParlData.ch API.
get_tables2()get_tables2()
A sorted character vector containing the names of the available OpenParlData REST API endpoints.
## Not run: # Get all available OpenParlData endpoints get_tables2() ## End(Not run)## Not run: # Get all available OpenParlData endpoints get_tables2() ## End(Not run)
get_variables retrieves the variable names of a table of the Swiss Parliament WebServices.
get_variables(table, pb.pos = NULL, pb = NULL)get_variables(table, pb.pos = NULL, pb = NULL)
table |
name of the table to be queried. For an
overview of available tables use |
pb.pos |
value for the progress bar. Not to be
specified outside of |
pb |
progress bar object. Not to be specified
outside of |
A sorted character vector containing the names of the variables.
## Not run: # Get variables of table "Person" get_variables(table = "Person") ## End(Not run)## Not run: # Get variables of table "Person" get_variables(table = "Person") ## End(Not run)
get_variables2 retrieves the field names of a resource provided by
the OpenParlData.ch REST API.
get_variables2(table, pb.pos = NULL, pb = NULL)get_variables2(table, pb.pos = NULL, pb = NULL)
table |
name of the OpenParlData resource to be
queried. For an overview of available endpoints use
|
pb.pos |
value for the progress bar. Not to be
specified outside of |
pb |
progress bar object. Not to be specified outside of
|
A sorted character vector containing the names of the fields available in the selected OpenParlData endpoint.
## Not run: # Get variables of OpenParlData resource "persons" get_variables2(table = "persons") ## End(Not run)## Not run: # Get variables of OpenParlData resource "persons" get_variables2(table = "persons") ## End(Not run)
ggswissparl plots voting results of the Swiss National Council according to the latest seating order.
ggswissparl( votes, seats = NULL, highlight, result = F, result_size = 6, point_shape = 16, point_size = 4, theme = "scoreboard" )ggswissparl( votes, seats = NULL, highlight, result = F, result_size = 6, point_shape = 16, point_size = 4, theme = "scoreboard" )
votes |
data of votes of the Swiss National Council as can be retrieved with |
seats |
data linking councillors ( |
highlight |
named list with variable and values to specify highlighting of selected councillors. |
result |
if |
result_size |
font size of result. |
point_shape |
shape of point as defined in |
point_size |
size of point. |
theme |
name of predefined plot theme:
|
A ggplot object. If votes contains multiple ballots, [ggplot2]{facet_wrap} is used to
create facets.
## Not run: # Visualization of a vote of the 51st legislature get_data("Voting", Language = "DE", IdVote = 23458) %>% ggswissparl() # Highlighting a parliamentary group get_data("Voting", Language = "DE", IdVote = 23458) %>% ggswissparl(highlight = list("ParlGroupNumber" = 2)) ## End(Not run)## Not run: # Visualization of a vote of the 51st legislature get_data("Voting", Language = "DE", IdVote = 23458) %>% ggswissparl() # Highlighting a parliamentary group get_data("Voting", Language = "DE", IdVote = 23458) %>% ggswissparl(highlight = list("ParlGroupNumber" = 2)) ## End(Not run)
A dataset containing the relative locations of the seats in the Swiss National Council to display schematic seating plans. A seat is defined by 4 corner points.
seating_planseating_plan
A data frame with 800 rows and 5 variables:
seat identifier.
corner identifier.
position of a corner point on the x-axis.
position of a corner point on the y-axis.
position of the seat center on the x-axis.
position of the seat center on the y-axis.
https://www.parlament.ch/en/organe/national-council/groups-chamber-nc