usa_extract <- define_extract_micro(
collection = "usa",
description = "2013-2014 ACS Data",
samples = c("us2013a", "us2014a"),
variables = c("SEX", "AGE", "YEAR")
)
usa_extract
# Use `var_spec()` to created detailed variable specifications:
usa_extract <- define_extract_micro(
collection = "usa",
description = "Example USA extract definition",
samples = c("us2013a", "us2014a"),
variables = var_spec(
"SEX",
case_selections = "2",
attached_characteristics = c("mother", "father")
)
)
# For multiple variables, provide a list of `var_spec` objects and/or
# variable names.
cps_extract <- define_extract_micro(
collection = "cps",
description = "Example CPS extract definition",
samples = c("cps2020_02s", "cps2020_03s"),
variables = list(
var_spec("AGE", data_quality_flags = TRUE),
var_spec("SEX", case_selections = "2"),
"RACE"
)
)
cps_extract
# To recycle specifications to many variables, it may be useful to
# create variables prior to defining the extract:
var_names <- c("AGE", "SEX")
my_vars <- purrr::map(
var_names,
~ var_spec(.x, attached_characteristics = "mother")
)
ipumsi_extract <- define_extract_micro(
collection = "ipumsi",
description = "Extract definition with predefined variables",
samples = c("br2010a", "cl2017a"),
variables = my_vars
)
# Extract specifications can be indexed by name
names(ipumsi_extract$samples)
names(ipumsi_extract$variables)
ipumsi_extract$variables$AGE
# IPUMS Time Use collections allow selection of IPUMS-defined and
# user-defined time use variables:
define_extract_micro(
collection = "atus",
description = "ATUS extract with time use variables",
samples = "at2007",
time_use_variables = list(
"ACT_PCARE",
tu_var_spec(
"MYTIMEUSEVAR",
owner = "example@example.com"
)
)
)
if (FALSE) {
# Use the extract definition to submit an extract request to the API
submit_extract(usa_extract)
}
Run the code above in your browser using DataLab