View source: R/api_define_extract.R
var_spec | R Documentation |
Provide specifications for individual variables when defining an IPUMS microdata extract request.
Currently, no additional specifications are available for IPUMS samples.
Learn more about microdata extract definitions in
vignette("ipums-api-micro")
.
var_spec(
name,
case_selections = NULL,
case_selection_type = NULL,
attached_characteristics = NULL,
data_quality_flags = NULL,
preselected = NULL
)
samp_spec(name)
name |
Name of the sample or variable. |
case_selections |
A character vector of values of the given variable that should be used to select cases. Values should be specified exactly as they appear in the "CODES" tab for the given variable in the web-based extract builder, including zero-padding (e.g. see the "CODES" tab for IPUMS CPS variable EDUC). |
case_selection_type |
One of Defaults to |
attached_characteristics |
Whose characteristics should be attached, if
any? Accepted values are |
data_quality_flags |
Logical indicating whether to include data quality flags for the given variable. By default, data quality flags are not included. |
preselected |
Logical indicating whether the variable is preselected. This is not needed for external use. |
A var_spec
or samp_spec
object.
var1 <- var_spec(
"SCHOOL",
case_selections = c("1", "2"),
data_quality_flags = TRUE
)
var2 <- var_spec(
"RACE",
case_selections = c("140", "150"),
case_selection_type = "detailed",
attached_characteristics = c("mother", "spouse")
)
# Use variable specifications in a microdata extract definition:
extract <- define_extract_usa(
description = "Example extract",
samples = "us2017b",
variables = list(var1, var2)
)
extract$variables$SCHOOL
extract$variables$RACE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.