euclideanPath: Compute path of the Euclidean distance between cases and/or...

View source: R/euclideanPath.R

euclideanPathR Documentation

Compute path of the Euclidean distance between cases and/or pumps.

Description

Compute path of the Euclidean distance between cases and/or pumps.

Usage

euclideanPath(origin = 1, destination = NULL, type = "case-pump",
  case.location = "address", case.set = "observed",
  landmark.cases = TRUE, vestry = FALSE, distance.unit = "meter",
  time.unit = "second", walking.speed = 5)

Arguments

origin

Numeric or Character. Numeric ID of case or pump. Character landmark name.

destination

Numeric or Character. Numeric ID(s) of case(s) or pump(s). Exclusion is possible via negative selection (e.g., -7). Default is NULL, which returns the closest pump, "anchor" case or landmark.

type

Character "case-pump", "cases" or "pumps".

case.location

Character. "address" or "orthogonal". For case.set = "observed": "address" uses fatalities and "orthogonal" uses ortho.proj. For case.set = "expected": "address" uses regular.cases and "orthogonal" uses sim.ortho.proj.

case.set

Character. "observed" or "expected".

landmark.cases

Logical. TRUE includes landmarks as cases.

vestry

Logical. TRUE uses the 14 pumps from the Vestry Report. FALSE uses the 13 pumps from the original map.

distance.unit

Character. Unit of distance: "meter", "yard" or "native". "native" returns the map's native scale. See vignette("roads") for information on unit distances.

time.unit

Character. "hour", "minute", or "second".

walking.speed

Numeric. Default is 5 km/hr.

Value

An R list with 3 data frames: x-y coordinates for the origin and destination, and a summary of results.

Note

The function uses a case's "address" (i.e., "anchor" case of a stack) to compute distance. Time is computed using distanceTime().

Examples

# path from case 1 to nearest pump.
euclideanPath(1)

# path from pump 1 to nearest case.
euclideanPath(NULL, 1)

# path from case 1 to pump 6.
euclideanPath(1, 6)

# exclude pump 7 from consideration.
euclideanPath(1, -7)

# path from case 1 to case 6.
euclideanPath(1, 6, type = "cases")

# path from pump 1 to pump 6.
euclideanPath(1, 6, type = "pumps")

# compute multiple cases.
lapply(1:3, euclideanPath)

# plot path
plot(euclideanPath(1))

lindbrook/cholera documentation built on April 14, 2024, 6:29 a.m.