get_data: Retrieve data from WebServices

Description Usage Arguments Value Examples

View source: R/get_data.R

Description

get_data retrieves data from the WebServices of the Swiss Parliament.

Usage

1
2
3
4
5
6
7
8
9
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## 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)

swissparl documentation built on Nov. 2, 2021, 9:11 a.m.