Learn R Programming

gsClusterDetect (version 1.0.0)

zip_distance_matrix: Get distance matrix for zip codes within a state

Description

Function returns a list of zipcodes and a matrix with the distance between those zip codes. leverages a built in dataset (`zipcodes`) that maps zipcodes to counties.

Usage

zip_distance_matrix(st, unit = c("miles", "kilometers", "meters"))

Value

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.

Arguments

st

two-character string denoting a state

unit

string, one of "miles" (default), "kilometers", or "meters". Indicating the desired unit for the distances

Examples

Run this code
zip_distance_matrix("MD")

Run the code above in your browser using DataLab