Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assign units to ors_matrix() results #52

Open
aoles opened this issue May 10, 2019 · 0 comments
Open

Assign units to ors_matrix() results #52

aoles opened this issue May 10, 2019 · 0 comments
Assignees
Labels
💡 enhancement New feature or request

Comments

@aoles
Copy link
Member

aoles commented May 10, 2019

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)

@aoles aoles added the 💡 enhancement New feature or request label May 10, 2019
@aoles aoles self-assigned this May 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant