get_argentine_senators: Get Current and Past Senators of Argentina
Description
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).
Usage
get_argentine_senators()
Arguments
Value
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).
Details
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.
if (FALSE) {
senators <- get_argentine_senators()
head(senators)
# Filter only currently active senatorsactive <- dplyr::filter(senators, Sys.Date() <= fin)
}