Skip to content

Assign units to ors_matrix() results #52

@aoles

Description

@aoles

Use units for the resulting matrix to facilitate conversion.

library(openrouteservice)
library(units)
#> udunits system database from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/units/share/udunits

coordinates = data.frame(
  lng = c(9.970093, 9.207916, 37.573242, 115.663757),
  lat = c(48.477473, 49.153868, 55.801281, 38.106467)
)

res <- ors_matrix(coordinates, sources = c(0, 2), destinations = c(1, 3))
m <- res$durations

m <- set_units(m, "secs")
m
#> Units: [s]
#>          [,1]     [,2]
#> [1,]  6299.06 400713.4
#> [2,] 89063.38 314298.8

units(m) <- "min"
m
#> Units: [min]
#>           [,1]     [,2]
#> [1,]  104.9843 6678.557
#> [2,] 1484.3897 5238.312

Created on 2019-05-10 by the reprex package (v0.2.1)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions