Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 在Googleway中使用Google_距离函数_R_Google Distancematrix Api_Googleway - Fatal编程技术网

R 在Googleway中使用Google_距离函数

R 在Googleway中使用Google_距离函数,r,google-distancematrix-api,googleway,R,Google Distancematrix Api,Googleway,使用此google_距离函数时,我无法理解输出。在ggmap中使用mydist()时,我将获得到达A点到B点所需的英里数、分钟数和小时数 现在,当我使用google_distance时,我的输出是这样的。有人能解释一下每个数字是指什么吗 $rows elements 1 791 km, 790588, 7 hours 28 mins, 26859, 7 hours 35 min

使用此google_距离函数时,我无法理解输出。在ggmap中使用mydist()时,我将获得到达A点到B点所需的英里数、分钟数和小时数

现在,当我使用google_distance时,我的输出是这样的。有人能解释一下每个数字是指什么吗

$rows
                                                            elements
1 791 km, 790588, 7 hours 28 mins, 26859, 7 hours 35 mins, 27286, OK
我的代码如下:

results <- google_distance(origins = list(c(26.19660, -98.23591)),
                          destinations = list(c(31.62327, -94.64276)), 
                          mode = "driving", key = key, simplify = TRUE)
results您看到的是,但简化为data.frame(根据
simplify=TRUE
参数)

如果你更深入地看一看你的回答,你会得到那些瓦勒斯的描述

results$rows$elements
# [[1]]
#   distance.text distance.value   duration.text duration.value duration_in_traffic.text duration_in_traffic.value
# 1        791 km         790588 7 hours 28 mins          26859          7 hours 28 mins                     26906
在哪里

  • 距离。值以米为单位
  • 持续时间。值以秒为单位
类似地,查看
result
对象的结构,您将看到所有JSON元素

str(results)
# List of 4
# $ destination_addresses: chr "805 E College St, Nacogdoches, TX, USA"
# $ origin_addresses     : chr "1400-1498 W Houston Ave, McAllen, TX 78501, USA"
# $ rows                 :'data.frame': 1 obs. of  1 variable:
#   ..$ elements:List of 1
# .. ..$ :'data.frame': 1 obs. of  4 variables:
#   .. .. ..$ distance           :'data.frame': 1 obs. of  2 variables:
#   .. .. .. ..$ text : chr "791 km"
# .. .. .. ..$ value: int 790588
# .. .. ..$ duration           :'data.frame':   1 obs. of  2 variables:
#   .. .. .. ..$ text : chr "7 hours 28 mins"
# .. .. .. ..$ value: int 26859
# .. .. ..$ duration_in_traffic:'data.frame':   1 obs. of  2 variables:
#   .. .. .. ..$ text : chr "7 hours 28 mins"
# .. .. .. ..$ value: int 26906
# .. .. ..$ status             : chr "OK"
# $ status               : chr "OK"

进一步参考:

您看到的是,但简化为data.frame(根据
simplify=TRUE
参数)

如果你更深入地看一看你的回答,你会得到那些瓦勒斯的描述

results$rows$elements
# [[1]]
#   distance.text distance.value   duration.text duration.value duration_in_traffic.text duration_in_traffic.value
# 1        791 km         790588 7 hours 28 mins          26859          7 hours 28 mins                     26906
在哪里

  • 距离。值以米为单位
  • 持续时间。值以秒为单位
类似地,查看
result
对象的结构,您将看到所有JSON元素

str(results)
# List of 4
# $ destination_addresses: chr "805 E College St, Nacogdoches, TX, USA"
# $ origin_addresses     : chr "1400-1498 W Houston Ave, McAllen, TX 78501, USA"
# $ rows                 :'data.frame': 1 obs. of  1 variable:
#   ..$ elements:List of 1
# .. ..$ :'data.frame': 1 obs. of  4 variables:
#   .. .. ..$ distance           :'data.frame': 1 obs. of  2 variables:
#   .. .. .. ..$ text : chr "791 km"
# .. .. .. ..$ value: int 790588
# .. .. ..$ duration           :'data.frame':   1 obs. of  2 variables:
#   .. .. .. ..$ text : chr "7 hours 28 mins"
# .. .. .. ..$ value: int 26859
# .. .. ..$ duration_in_traffic:'data.frame':   1 obs. of  2 variables:
#   .. .. .. ..$ text : chr "7 hours 28 mins"
# .. .. .. ..$ value: int 26906
# .. .. ..$ status             : chr "OK"
# $ status               : chr "OK"

进一步参考:


代码示例或R笔记本的链接会有所帮助。我找了一些文件,但很难找到答案,所以这里有一个真正的问题。关于为什么医生没有答案的问题,我无法回答。我希望这个问题能得到正确的文档链接的回答,因为这将是有帮助的。谢谢!我在问题中添加了我的代码。代码示例或R笔记本的链接会很有帮助。我找了一些文件,但很难找到答案,所以这里有一个真正的问题。关于为什么医生没有答案的问题,我无法回答。我希望这个问题能得到正确的文档链接的回答,因为这将是有帮助的。谢谢!我在问题中添加了我的代码。当我在原点和终点传递值向量时会发生什么?我得到的是
result距离矩阵(从
google_Distance()
返回)返回所有起点和终点组合之间的距离。如果你想要一个“成对”的响应,你必须写一个循环(可能使用
google_directions()
来获取更多细节)类似的东西(也有其他的浮动),但是,如果你只想要距离,而不关心方向、时间或任何事情,那么我推荐
geodist::geodist_vec(…,paired=TRUE)
非常感谢,这非常有帮助:)当我在原点和终点传递值向量时会发生什么?我得到的是
result距离矩阵(从
google_Distance()
返回)返回所有起点和终点组合之间的距离。如果你想要一个“成对”的响应,你必须写一个循环(可能使用
google_directions()
来获取更多细节)类似的东西(也有其他的浮动),但是,如果你只想要距离,而不关心方向、时间或任何事情,那么我推荐
geodist::geodist_vec(…,paired=TRUE)
非常感谢,这非常有帮助:)