View source: R/get_argentine_senators.R
get_argentine_senators | R Documentation |
This function retrieves a list of senators from the Argentine Senate API endpoint: 'https://api.argentinadatos.com/v1/senado/senadores'. The result includes name, province, party affiliation, and their legal term of office. The results are sorted by the start of their legal term in descending order (most recent first).
get_argentine_senators()
The function parses the nested JSON structure returned by the API, extracts the period data, and ensures that 'inicio' and 'fin' are treated as proper 'Date' objects. The data is sorted by 'inicio' in descending order to prioritize currently active or recently active senators.
A data frame (tibble) with the following columns:
id
: Unique identifier of the senator.
nombre
: Full name of the senator.
provincia
: Province represented.
partido
: Political party.
inicio
: Start date of the legal period (Date).
fin
: End date of the legal period (Date).
Requires internet access. Be cautious with malformed or missing date fields.
GET
, fromJSON
, arrange
## Not run:
senators <- get_argentine_senators()
head(senators)
# Filter only currently active senators
active <- dplyr::filter(senators, Sys.Date() <= fin)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.