get_category_strings {RcensusPkg} | R Documentation |
get_category_strings
Description
For a Census Bureau categorical variable return a data.table
with the
variable's integer values and corresponding label strings.
The function will attempt to locate a Bureau's categorical variable by name and
return a data.table
with both the integer values and corresponding label strings. If
the variable is not located then NULL is returned. Definitions for the variables were
obtained from
Population Estimates Categorical Variables
and other Bureau sources.
Usage
get_category_strings(
name = NULL,
get_names = FALSE,
start_idx = NULL,
end_idx = NULL
)
Arguments
name |
A required string that is the name of the categorical variable of interest. |
get_names |
An optional logical which if |
start_idx |
An optional integer that sets the starting index of the variable's integer/label pairs.
If the value is |
end_idx |
An optional integer that sets the ending row index of the returned variable's integer/label pairs. |
Value
A data.table
with the variable's integer values and corresponding label strings.
Examples
library(data.table)
library(RcensusPkg)
# Get the names currently supported category variables
category_names_v <- RcensusPkg::get_category_strings(get_names = TRUE)
# Get the integer/string pairs for the category name "sex"
sex_category_dt <- RcensusPkg::get_category_strings(name = "sex")