r - 号有没有限制。我可以在循环中进行的 HERE API 调用(使用 R)
问题描述
我正在尝试遍历原始目的地经纬度位置列表以获取运输时间。循环时出现以下错误。但是,当我进行一次调用(不循环)时,我得到一个没有错误的输出。我使用免费增值的 HERE-API,每月可以进行 25 万笔交易。
`for (i in 1:nrow(test))
{
call <- paste0("https://route.api.here.com/routing/7.2/calculateroute.json",
"?app_id=","appid",
"&app_code=","appcode",
"&waypoint0=geo!",y$dc_lat[i],",",y$dc_long[i],
"&waypoint1=geo!",y$store_lat[i],",",y$store_long[i],
"&mode=","fastest;truck;traffic:enabled",
"&trailerscount=","1",
"&routeattributes=","sh",
"&maneuverattributes=","di,sh",
"&limitedweight=","20")
response <-fromJSON(call, simplify = TRUE)
Traffic_time = (response[["response"]][["route"]][[1]][["summary"]][["trafficTime"]]) / 60
Base_time = (response[["response"]][["route"]][[1]][["summary"]][["baseTime"]]) / 60
print(Traffic_time)
}`
Error in file(con, "r"): cannot open the connection to 'https://route.api.here.com/routing/7.2/calculateroute.json?app_id=appid&app_code=appcode&waypoint0=geo!45.1005200,-93.2452000&waypoint1=geo!45.0978500,-95.0413620&mode=fastest;truck;traffic:enabled&trailerscount=1&routeattributes=sh&maneuverattributes=di,sh&limitedweight=20' Traceback:
解决方案
根据错误,这表明您最后的文件存在问题。它可能已损坏,最好尝试更改文件的扩展名。也可以尝试重启你的IDE。API 调用的数量取决于您选择免费增值计划或专业计划的计划。您可以了解更多详细信息:https ://developer.here.com/faqs
推荐阅读
- rest - 如何通过rest api从yammer中提取基于人口统计的活动?
- c# - DataTable.AsEnumerable() 中的 C# Nullreferenceexception 在哪里
- cucumber - 如何为所有 Cucumber 步骤添加默认超时?
- reactjs - 优化组件树
- react-native - Native Base - 放置在 Header 中的组件不是垂直居中的 react-native
- java - 调用对象时,这些括号是什么意思?
- javascript - Google Analytics Reporting API:Javascript 中的活跃用户数
- c# - .NET Core 2 项目的 StackExchange.Exceptional 错误的 URL 是什么?
- html - 如何处理多选项卡式 html 表单上的验证,我如何知道存在验证错误
- javascript - 通过 jquery 选择单选按钮(按值或按 id)