add_to_extract_micro | R Documentation |
Add new values or replace existing values in an IPUMS microdata 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_micro()
.
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 microdata extract definition, use
remove_from_extract()
.
Learn more about the IPUMS API in vignette("ipums-api")
.
## S3 method for class 'micro_extract'
add_to_extract(
extract,
description = NULL,
samples = NULL,
variables = NULL,
time_use_variables = NULL,
sample_members = NULL,
data_format = NULL,
data_structure = NULL,
rectangular_on = NULL,
case_select_who = NULL,
data_quality_flags = NULL,
...
)
extract |
An |
description |
Description of the extract. |
samples |
Vector of samples to include in the extract
request. Use |
variables |
Character vector of variable names or a list of
If a variable already exists in the extract, its specifications will be added to those that already exist for that variable. |
time_use_variables |
Vector of names of IPUMS-defined time use variables
or a list of specifications for user-defined time use variables
to include in the extract request. Use |
sample_members |
Indication of whether to include additional sample
members in the extract request. If provided, must be one of
Sample member selection is only available for the IPUMS ATUS collection
( |
data_format |
Format for the output extract data file. Either
Note that while |
data_structure |
Data structure for the output extract data.
|
rectangular_on |
If Defaults to |
case_select_who |
Indication of how to interpret any case selections included for variables in the extract definition.
Defaults to |
data_quality_flags |
Set to Use |
... |
Ignored |
If the supplied extract definition comes from a previously submitted extract request, this function will reset the definition to an unsubmitted state.
To modify variable-specific parameters for variables that already exist
in the extract, create a new variable specification with var_spec()
.
A modified micro_extract
object
remove_from_extract()
to remove
values from an extract definition.
submit_extract()
to submit an extract request.
download_extract()
to download extract data files.
define_extract_micro()
to create a new extract
definition from scratch
extract <- define_extract_micro(
collection = "usa",
description = "2013 ACS Data",
samples = "us2013a",
variables = c("SEX", "AGE", "YEAR")
)
# Add a single sample
add_to_extract(extract, samples = "us2014a")
# Add samples and variables
extract2 <- add_to_extract(
extract,
samples = "us2014a",
variables = c("MARST", "BIRTHYR")
)
# Modify specifications for variables in the extract by using `var_spec()`
# with the existing variable name:
add_to_extract(
extract,
samples = "us2014a",
variables = var_spec("SEX", case_selections = "2")
)
# You can make multiple modifications or additions by providing a list
# of `var_spec()` objects:
add_to_extract(
extract,
samples = "us2014a",
variables = list(
var_spec("RACE", attached_characteristics = "mother"),
var_spec("SEX", case_selections = "2"),
var_spec("RELATE")
)
)
# Values that only take a single value are replaced
add_to_extract(extract, description = "New description")$description
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.