View source: R/location_functions.R
| create_dist_list | R Documentation |
This function is an alternative to the package functions that create a square distance matrix of dimension N, with all pairwise distances. In this approach a list of named vectors is returned, where there is one element in the list for each location, and each named vector holds the distance within 'threshold' of the location.
create_dist_list(
level,
threshold,
st = NULL,
county = NULL,
unit = c("miles", "kilometers", "meters")
)
level |
string either "state", "county", "zip", or "tract" |
threshold |
numeric value; include in each location-specific named vector only those locations that a within 'threshold' distance units of the target. Reasonable thresholds might be 250 (miles), 50 (miles), 15 (miles) and 3 (miles) for county, zip, and tract, respectively, but these can be adjusted. Note if a different unit other than miles is used, then the user should also adjust this parameter appropriately |
st |
string; optional to specify a state; if NULL distances are returned for all zip codes, counties, or states in the US |
county |
string vector of 3-fips to restrict within |
unit |
string one of miles (default), kilometers, or meters; this is the unit relevant to the threshold |
a named list, where each element, named by a target location, is a named vector of distances that are within 'threshold' 'units' of the target.
create_dist_list(
level = "tract",
threshold = 3,
st = "MD"
)
create_dist_list(
level = "county",
threshold = 50,
st = "CA",
unit = "kilometers"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.