Description Usage Arguments Value Author(s) See Also Examples
This function builds the pairwise distance matrix from vectors of XY coordinates and associated names.
1 | get_distance_matrix(x, y, id)
|
x |
vector giving X coordinates |
y |
vector giving Y coordinates |
id |
vector of names for each location |
a named matrix of pairwise distances among locations
John Giles
Other data synthesis:
get_crossdist()
,
get_mob_matrix()
,
get_stay_data()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | n <- 5
xy <- data.frame(x=rnorm(n, -90, 1),
y=rnorm(n, 30, 1),
id=LETTERS[1:n])
D <- get_distance_matrix(x=xy[,1],
y=xy[,2],
id=xy[,3])
# From simulated travel data
xy <- get_unique_coords(travel_data_sim)
D <- get_distance_matrix(x=xy[,1],
y=xy[,2],
id=xy[,3])
D*111.35 # decimal degrees to km
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.