get_data {swissparl}R Documentation

Retrieve data from WebServices

Description

get_data retrieves data from the WebServices of the Swiss Parliament.

Usage

get_data(
  table,
  package_size = 1000,
  stop = T,
  attempts = 10,
  wtf = 1,
  silent = F,
  ...
)

Arguments

table

name of the table to download. For an overview of available tables use get_tables().

package_size

number of rows to download at once (maximum = 1000). If a query exceeds package_size, it is internally split into multiple subqueries of size package_size.

stop

if TRUE, the query process is interrupted if the query is invalid. It also indicates whether a non-existent table or variable was used in the query. If FALSE, nothing is returned.

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 wtf = 1, the waiting time corresponds to the number of unsuccessful attempts in seconds. For attemps = 10 and wtf = 1, a query is repeated for a maximum of 45 seconds. The waiting time increases proportionally with wtf.

silent

if TRUE, no progress bar and messages are displayed.

...

optional filter arguments with values. Since all entries are available in several languages, it is recommended to filter the calls by language., e.g. get_data(table = "Person", Language = "DE"). For a table-specific preview use get_glimpse() or get_variables(). The following things are to consider:

  • numbers for identification numbers, for example, must be entered as numeric vectors: e.g. get_data(table = "Voting", PersonNumber = c(21, 4167), Language = "DE").

  • dates must be entered as character vectors in yyyy-mm-dd format. > and < can be used to query periods: e.g. get_data(table = "Bill", SubmissionDate = c(">2018-12-31", "<2019-02-01"), Language = "DE").

  • the '~' can be used as substring search for character variables: e.g. get_data(table = "Bill", Title = "~CO2", Language = "DE").

Value

A tibble of different length and variable composition.

Examples

## 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)

[Package swissparl version 0.2.2 Index]