View source: R/get_elections.R
get_elections | R Documentation |
The get_* functions from cepespR extract alternative slices of the processed TSE data avaiable at CEPESPData.
* get_elections()
is the most comprehensive function which
merges data on election results, candidates and coalitions to
enable more complex analysis. Be aware that this function still is in development.
* get_votes()
extracts details about the number of votes won by each
candidate in a specific election.
* get_candidates()
extracts details about the characteristics of individual
candidates competing in an election.
* get_coalitions()
extracts details about the parties that constitute each
coalition that competed in each election.
get_elections(
year,
position,
state = "all",
regional_aggregation = "Municipality",
political_aggregation = "Candidate",
cached = FALSE,
columns_list = list(),
party = NULL,
candidate_number = NULL,
only_elected = FALSE,
dev = FALSE,
blank_votes = FALSE,
null_votes = FALSE,
lambda = FALSE
)
get_votes(
year,
position,
regional_aggregation = "Municipality",
state = "all",
cached = FALSE,
columns_list = list(),
party = NULL,
candidate_number = NULL,
dev = FALSE,
blank_votes = FALSE,
null_votes = FALSE,
lambda = FALSE
)
get_candidates(
year,
position,
cached = FALSE,
columns_list = list(),
party = NULL,
candidate_number = NULL,
only_elected = FALSE,
dev = FALSE,
lambda = FALSE
)
get_coalitions(
year,
position,
columns_list = list(),
party = NULL,
cached = FALSE,
dev = FALSE,
lambda = FALSE
)
year |
a integer scalar |
position |
a character or intecer scalar with the correpondend political contest position. |
state |
character vector. Default value is "all". |
regional_aggregation |
character with desired regional aggregation. |
political_aggregation |
character with desired political aggregation. |
cached |
a logical scalar. If TRUE, |
columns_list |
a list with the columns needed. If supplied, |
party |
Optional character with a specified party. |
candidate_number |
Optional integer scalar. |
get_elections()
is a function in development. Thus, merges performed by it remain
imperfect due to errors in the underlying TSE data and so this function should be
treated as beta and used with caution.
The default setting is for the function to return all the available variables (columns). To select specific variables and limit the size of the request, you can specify a list of required columns in the columns_list property. The specific columns available depend on the political and regional aggregation selected so you are advised to refer to the API documentation at https://github.com/Cepesp-Fgv/cepesp-rest for further details.
To limit the size of the data returned by the API, the request can be filtered to return data on specific units: By state (using the two-letter abbreviation, eg. "RJ"); by party (using the two-digit official party number, eg. 45), or by candidate number.
Each time a request is made to the cepesp-R API, the specific dataset is constructed and downloaded to your local system. To limit processing and bandwidth utilization, the cepespR package includes the option to cache your requests so that they are stored locally and immediately available when that request is repeated.
Note that if you use this feature the app will create a sub-directory /static/cache of your working directory to store the downloaded data. You can manually delete this data to force a new download the next time the same request is made.
## Not run:
#Basic use of get_* functions.
data <- get_elections(year = 2014, position = "Federal Deputy")
data <- get_votes(year = 2014, position = "Federal Deputy")
data <- get_candidates(year = 2014, position = "Federal Deputy")
data <- get_coalitions(year = 2014, position = "Federal Deputy")
#If needed, it is possible to change regional and political aggregation
data <- get_elections(year = 2014,
position = "Federal Deputy",
regional_aggregation = "State",
political_aggregation = "Party")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.