我试图计算两个坐标位置之间的驾驶距离。下面是我的代码:
library(tidyverse)
library(googleway)
distances %>%
mutate(distance = google_distance(origins = origin, destinations = destination, key = 'API KEY'))
这是我的数据集- https://pastebin.com/d6Z6b2K5
我得到这个错误:
Error in mutate():
! Problem while computing distance = google_distance(...).
✖ distance must be size 294 or 1, not 5.
我真的很感激你的帮助!
这是我的解决方案
mutate(distance = purrr::map2(origin, destination, ~ google_distance(.x, .y, key = 'API KEY')))