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
Run the code above in your browser using DataLab