View source: R/api_define_extract.R
remove_from_extract.micro_extract | R Documentation |
Remove existing values from an IPUMS microdata extract definition. All fields are optional, and if omitted, will be unchanged.
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_*()
functions.
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 add new values to an IPUMS microdata extract definition, see
add_to_extract()
.
Learn more about the IPUMS API in vignette("ipums-api")
.
## S3 method for class 'micro_extract'
remove_from_extract(extract, samples = NULL, variables = NULL, ...)
extract |
An |
samples |
Character vector of sample names to remove from the extract definition. |
variables |
Names of the variables to remove from the extract definition. All variable-specific fields for the indicated variables will also be removed. |
... |
Ignored |
If the supplied extract definition comes from a previously submitted extract request, this function will reset the definition to an unsubmitted state.
To retain a variable while modifying its particular specifications, first
remove that variable, then add a new specification using add_to_extract()
.
A modified micro_extract
object
add_to_extract()
to add values
to an extract definition.
submit_extract()
and download_extract()
to submit and process an
extract request.
define_extract_*()
to create a new extract
definition from scratch.
usa_extract <- define_extract_usa(
description = "USA example",
samples = c("us2013a", "us2014a"),
variables = list(
var_spec("AGE", data_quality_flags = TRUE),
var_spec("SEX", case_selections = "1"),
"RACE"
)
)
# Providing names of samples or variables will remove them and
# all of their associated specifications from the extract:
remove_from_extract(
usa_extract,
samples = "us2014a",
variables = c("AGE", "RACE")
)
# To remove detailed specifications from a variable, indicate the
# specifications to remove within `var_spec()`. The
# named variable will be retained in the extract, but modified by
# removing the indicated specifications.
remove_from_extract(
usa_extract,
variables = var_spec("SEX", case_selections = "1")
)
# To make multiple modifications, use a list of `var_spec()` objects.
remove_from_extract(
usa_extract,
variables = list(
var_spec("SEX", case_selections = "1"),
var_spec("AGE")
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.