Define a NHGIS time series extract using ipumsr::define_extract_nhgis
Source: R/get_nhgis_ts_data.R
define_nhgis_ts_extract.Rddefine_nhgis_ts_extract() is a wrapper for ipumsr::define_extract_nhgis()
with defaults that support the creation of tidy data using
read_nhgis_data() or pivot_nhgis_data().
Usage
define_nhgis_ts_extract(
year = NULL,
tables = NULL,
geography = c("county", "state"),
extent = "us",
output = c("tidy", "wide", "file"),
shape_year = NULL,
basis = 2008,
geometry = FALSE,
...,
time_series_tables = NULL,
description = NULL,
shapefiles = NULL,
data_format = "csv_no_header",
validate = TRUE,
api_key = Sys.getenv("IPUMS_API_KEY")
)Arguments
- output
Used to set
tst_layoutvalue. c("tidy", "wide", "file") corresponding to "time_by_row_layout", "time_by_column_layout", or "time_by_file_layout".- geometry
If
TRUE, include shapefiles in the defined extract. If shapefiles isNULL, the function useslist_nhgis_shapefiles()withshape_yearas theyearparameter.- ...
Arguments passed on to
ipumsr::define_extract_nhgisdatasetsList of dataset specifications for any datasets to include in the extract request. Use
ds_spec()to create ads_specobject containing a dataset specification. See examples.geographic_extentsVector of geographic extents to use for all of the
datasetsandtime_series_tablesin the extract definition (for instance, to obtain data within a specified state). By default, selects all available extents.Use
get_metadata()to identify the available extents for a given dataset or time series table, if any.breakdown_and_data_type_layoutThe desired layout of any
datasetsthat have multiple data types or breakdown values."single_file"(default) keeps all data types and breakdown values in one file"separate_files"splits each data type or breakdown value into its own file
Required if any
datasetsincluded in the extract definition consist of multiple data types (for instance, estimates and margins of error) or have multiple breakdown values specified. Seeget_metadata()to determine whether a requested dataset has multiple data types.
- time_series_tables
List of time series table specifications for any time series tables to include in the extract request. Use
tst_spec()to create atst_specobject containing a time series table specification. See examples.- description
Description of the extract.
- shapefiles
Names of any shapefiles to include in the extract request.
- data_format
The desired format of the extract data file.
"csv_no_header"(default) includes only a minimal header in the first row"csv_header"includes a second, more descriptive header row."fixed_width"provides data in a fixed width format
Note that by default,
read_ipums_agg()removes the additional header row in"csv_header"files.Required when an extract definition includes any
datasetsortime_series_tables.- api_key
API key associated with your user account. Defaults to the value of the
IPUMS_API_KEYenvironment variable. Seeset_ipums_api_key().