| Type: | Package |
| Title: | A Functional Tool for 'CongressData' |
| Version: | 1.5.5 |
| Description: | A tool that imports, subsets, and exports the 'CongressData' dataset. 'CongressData' contains approximately 800 variables concerning all US congressional districts with data back to 1789. The dataset tracks district characteristics, members of Congress, and the political behavior of those members. Users with only a basic understanding of R can subset this data across multiple dimensions, export their search results, identify the citations associated with their searches, and more. |
| License: | GPL-3 |
| Encoding: | UTF-8 |
| Language: | en-US |
| RoxygenNote: | 7.3.1 |
| Depends: | R (≥ 3.50) |
| Imports: | stringr, dplyr, rlang, fst, curl, tidyselect |
| NeedsCompilation: | no |
| Packaged: | 2025-06-19 10:00:44 UTC; caleb |
| Author: | Caleb Lucas [aut, cre], Ben Yoel [ctb] |
| Maintainer: | Caleb Lucas <calebjlucas@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2025-06-19 10:10:02 UTC |
Load CongressData into the R environment
Description
get_cong_data loads either a full or subsetted version of the fullCongressData dataset into the R environment as a dataframe.
Usage
get_cong_data(states = NULL, related_to = "", years = NULL)Arguments
states | Default is NULL. If left blank, returns all states. Takes astring or vector of strings of state names. |
related_to | Default is "". Provide a string to search a variable's name,short/long descriptions from the codebook, and its citation for non-exact matches of a search term. For example, searching 'tax' will return variables with wordslike 'taxes' and 'taxable' in any of those columns. |
years | Default is NULL. If left blank, returns all years Input can bea single year (e.g. 2001) or a two year that represent the first and lastthat you want in the outputted dataframe (such as |
Value
An object of type tibble containing CongressData. The tibble has columns correspondingto variables in the dataset, and rows corresponding to observations that matchthe filtering criteria specified by thestates,related_to, andyears parameters.
Get your local version of CongressData
Description
get_congress_version prints the current version of CongressData available through the package. It takes no arguments.
Usage
get_congress_version()Value
No return value, called for side effects.
Get information regarding CongressData variables
Description
get_var_info retrieves information regarding variables in the CongressData dataset.The information available includes: the years each variable is observed in the data;a short and long description of each variable; and the source and citation/s for eachvariable. Citations are available in both bibtex and plain text.
Usage
get_var_info(var_names = NULL, related_to = NULL)Arguments
var_names | Default is NULL. Takes a character string. If left blank thefunction does not subset by variable name. Note that this searches variable names,it does not subset by the specific string you provide. So "over65" will return avariable called 'over65' along with another called 'percent_over65'. |
related_to | Default is NULL. Takes a character string. If the user suppliesa character string, the function searches the other relevant fields (variable name, short/longdescription, and source) for string matches. Not case sensitive. |
Details
Specifying no arguments returns all the information for all the variablesin the CongressData dataset.
Value
A tibble with information about variables in the CongressData dataset.The tibble contains the following columns:
variable: The name of the variable.years: The years the variable is observed.short_desc: A short description of the variable.long_desc: A long description of the variable.source: The source of the data.citation: The citation for the data, available in bibtex and plain text.
The tibble is filtered based on the providedvar_names andrelated_to parameters.
Examples
# returns all variable informationget_var_info()# match var names that contain "over65" - note this returns multiple variablesget_var_info(var_names = "over65")get_var_info(related_to = c("pop","femal"))