Learn R Programming

gsClusterDetect (version 1.0.0)

create_custom_dist_list: Create a sparse distance list from custom location data

Description

This function is a custom-data version of create_dist_list(). It returns a list of named numeric vectors where each list element contains only locations within threshold distance units of a target location.

Usage

create_custom_dist_list(
  df,
  label_var,
  lat_var,
  long_var,
  threshold,
  unit = c("miles", "kilometers", "meters")
)

Value

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.

Arguments

df

data.frame containing label and coordinate columns

label_var

character scalar; column name used as location label (must be unique and non-missing)

lat_var

character scalar; latitude column name.

long_var

character scalar; longitude column name.

threshold

numeric scalar distance cutoff in units of unit

unit

string, one of "miles" (default), "kilometers", or "meters"

Examples

Run this code
# \donttest{
md <- tract_generator("MD")
dlist <- create_custom_dist_list(
  df = md,
  label_var = "geoid",
  lat_var = "latitude",
  long_var = "longitude",
  threshold = 15,
  unit = "miles"
)
# }

Run the code above in your browser using DataLab