View source: R/state_to_region.R
state_to_region | R Documentation |
This function works with title case names of the 50 states and D.C., as well as with all caps 2-letter abbreviations with and without periods (e.g., NJ and N.J.). Default regions are defined by the U.S. Census.
state_to_region(
data,
state.var = state,
region.var = region,
factorize = TRUE,
region.levels = c("Northeast", "Midwest", "South", "West")
)
data |
A data frame or data frame extension (e.g. a tibble) |
state.var |
Variable containing state values. Defaults to state |
region.var |
Variable to be created containing regions. Defaults to region |
factorize |
A logical evaluation to TRUE or FALSE indicating whether to make the region.var a factor. Defaults to TRUE |
region.levels |
An optional vector of the unique values (as character strings) that region.var might have taken. Defaults to c("Northeast", "Midwest", "South", "West") |
A data frame
USArrests |> tibble::rownames_to_column("us_state") |>
state_to_region(us_state, us_region)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.