View source: R/api_define_extract.R
add_to_extract.nhgis_extract | R Documentation |
Add new values to an IPUMS NHGIS extract definition.
All fields are optional, and if omitted, will be unchanged.
Supplying a value for fields that take a single value, such as
description
and data_format
, will replace the existing value with
the supplied value.
This function is marked as experimental because it is typically not the best
option for maintaining reproducible extract definitions and may be retired
in the future. For reproducibility, users should strive to build extract
definitions with define_extract_nhgis()
.
If you have a complicated extract definition to revise, but do not have
the original extract definition code that created it, we suggest that you
save the revised extract as a JSON file with save_extract_as_json()
. This
will create a stable version of the extract definition that
can be used in the future as needed.
To remove existing values from an IPUMS NHGIS extract definition, use
remove_from_extract()
.
Learn more about the IPUMS API in vignette("ipums-api")
.
## S3 method for class 'nhgis_extract'
add_to_extract(
extract,
description = NULL,
datasets = NULL,
time_series_tables = NULL,
geographic_extents = NULL,
shapefiles = NULL,
breakdown_and_data_type_layout = NULL,
tst_layout = NULL,
data_format = NULL,
...
)
extract |
An |
description |
Description of the extract. |
datasets |
List of If a dataset already exists in the extract, its new specifications will be added to those that already exist for that dataset. |
time_series_tables |
List of If a time series table already exists in the extract, its new specifications will be added to those that already exist for that time series table. |
geographic_extents |
Vector of geographic extents to use for
all of the Required when any of the |
shapefiles |
Names of any shapefiles to include in the extract request. |
breakdown_and_data_type_layout |
The desired layout
of any
Required if any |
tst_layout |
The desired layout of all
Required when an extract definition includes any |
data_format |
The desired format of the extract data file.
Note that by default, Required when an extract definition includes any |
... |
Ignored |
For extract fields that take a single value, add_to_extract()
will
replace the existing value with the new value provided for that field.
It is not necessary to first remove this value using
remove_from_extract()
.
If the supplied extract definition comes from a previously submitted extract request, this function will reset the definition to an unsubmitted state.
A modified nhgis_extract
object
remove_from_extract()
to remove
values from an extract definition.
define_extract_nhgis()
to create a new extract definition.
submit_extract()
to submit an extract request.
download_extract()
to download extract data files.
extract <- define_extract_nhgis(
datasets = ds_spec("1990_STF1", c("NP1", "NP2"), "county")
)
# Add a new dataset or time series table to the extract
add_to_extract(
extract,
datasets = ds_spec("1990_STF2a", "NPA1", "county")
)
add_to_extract(
extract,
time_series_tables = tst_spec("A00", "state")
)
# If a dataset/time series table name already exists in the definition
# its specification will be modified by adding the new specifications to
# the existing ones
add_to_extract(
extract,
datasets = ds_spec("1990_STF1", "NP4", "nation")
)
# You can add new datasets and modify existing ones simultaneously by
# providing a list of `ds_spec` objects
add_to_extract(
extract,
datasets = list(
ds_spec("1990_STF1", "NP4", "nation"),
ds_spec("1990_STF2a", "NPA1", "county")
)
)
# Values that can only take a single value are replaced
add_to_extract(extract, data_format = "fixed_width")$data_format
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.