View source: R/location_functions.R
| county_distance_matrix | R Documentation |
Function returns a list of counties and a matrix with the distance between those counties. leverages a built in dataset ('counties').
county_distance_matrix(
st,
unit = c("miles", "kilometers", "meters"),
source = c("tigris", "rnssp")
)
st |
two-character string denoting a state, or "US". If "US", then this
is equivalent to calling |
unit |
string, one of "miles" (default), "kilometers", or "meters". Indicating the desired unit for the distances |
source |
string indicating either "tigris" (default) or "rnssp". Both are built-in datasets (i.e. are part of this package). The default ("tigris") uses county names and locations as found in tigris 2024. The "rnssp" option uses a package-stored version of the publicly available shape file for counties from Rnssp package at https://cdcgov.github.io/Rnssp/ |
a named list of length two; first element ('loc_vec') is a vector of locations and the second element ('distance_matrix') is a square matrix containing the pairwise distance (in the given 'unit') between all locations.
county_distance_matrix("MD", source = "tigris")
county_distance_matrix("WI", source = "rnssp", unit = "kilometers")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.