dplyr_select_style | R Documentation |
Several arguments in ipumsr
allow syntax for selecting variables
based on dplyr's select
function. See details for more information.
There are 3 broad categories of methods for specifying arguments for these select-style parameters.
"Character Vector"A character vector of names (such as c("var1", "var2", "var3")
)
"'Bare' Vector"A vector of 'bare' names (such as c(var1, var2, var3)
)
"Helper Functions"Helper functions from dplyr::select
such as
starts_with()
, contains
and others.
# For microdata, use this syntax to load variables # Load 3 variables by name cps_file <- ipums_example("cps_00006.xml") data <- read_ipums_micro(cps_file, vars = c("YEAR", "MONTH", "PERNUM")) # Load same 3 variables using bare names data <- read_ipums_micro(cps_file, vars = c(YEAR, MONTH, PERNUM)) # Use helper functions to load all variables that start with "WT" data <- read_ipums_micro(cps_file, vars = starts_with("WT")) # Use bare names and helper function to load YEAR, MONTH and all variables with 'INC' in name data <- read_ipums_micro(cps_file, vars = c(YEAR, MONTH, contains("INC"))) # For geographic extracts, `data_layer` and `shape_layer` arguments use the same conventions # to select file names from within zip files. # (This extract only contains 1 type of file, but some have multiple) csv_file <- ipums_example("nhgis0008_csv.zip") data <- read_nhgis( csv_file, data_layer = contains("pmsa") )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.