Subset Data by Geographic Area
subset_by_geography.RdFilters prepared datasets to a specific geographic subset (state, region, or custom list of geographic IDs).
Usage
subset_by_geography(
data,
id_col = "GEOID10",
state_fips = NULL,
geoid_list = NULL,
geoid_pattern = NULL
)Arguments
- data
A data.table or data frame to subset.
- id_col
Character. Column name for geographic IDs. Default is "GEOID10".
- state_fips
Optional character vector. Two-digit state FIPS codes to include. Data will be filtered to counties within these states.
- geoid_list
Optional character vector. Specific geographic IDs to include.
- geoid_pattern
Optional character. Regular expression pattern to match geographic IDs.
Examples
if (FALSE) { # \dontrun{
# Subset to California counties (state FIPS = "06")
ca_data <- subset_by_geography(
data = prob_data,
state_fips = "06"
)
# Subset to specific counties
selected <- subset_by_geography(
data = prob_data,
geoid_list = c("06001", "06003", "06005")
)
} # }