View source: R/api_define_extract.R
var_spec | R Documentation |
Provide specifications for individual variables and time use variables when defining an IPUMS microdata extract request.
Currently, no additional specifications are available for IPUMS samples.
Note that not all variable-level options are available across all IPUMS data collections. For a summary of supported features by collection, see the IPUMS API documentation.
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
)
tu_var_spec(name, owner = NULL)
samp_spec(name)
name |
Name of the sample, variable, or time use 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 For data collections with information on same-sex couples, specifying
|
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. |
owner |
For user-defined time use variables, the email of the user account associated with the time use variable. Currently, only the email of the user submitting the extract request is supported. |
A var_spec
, tu_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_micro(
collection = "usa",
description = "Example extract",
samples = "us2017b",
variables = list(var1, var2)
)
extract$variables$SCHOOL
extract$variables$RACE
# For IPUMS Time Use collections, use `tu_var_spec()` to include user-defined
# time use variables
my_time_use_variable <- tu_var_spec(
"MYTIMEUSEVAR",
owner = "example@example.com"
)
# IPUMS-defined time use variables can be included either as `tu_var_spec`
# objects or with just the variable name:
define_extract_micro(
collection = "atus",
description = "Requesting user- and IPUMS-defined time use variables",
samples = "at2007",
time_use_variables = list(
my_time_use_variable,
tu_var_spec("ACT_PCARE"),
"ACT_SOCIAL"
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.