Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/72.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.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
data.frame(…,check.names=FALSE)中出错:循环_R_Loops_Google Cloud Platform - Fatal编程技术网

data.frame(…,check.names=FALSE)中出错:循环

data.frame(…,check.names=FALSE)中出错:循环,r,loops,google-cloud-platform,R,Loops,Google Cloud Platform,我正在处理大数据。我有两个数据集作为起点和终点。使用GoogleAPI,我想计算从原始数据集到目标数据集的方向。数据如下: Origin(masterdata): No xcoord ycoord 1 109.6663 -6.897970 2 109.6584 -6.897511 3 109.6519 -6.893822 4 109.6586 -6.896936 5 109.6651 -6.897484 Destination(xystation3375) No Long Lat 1

我正在处理大数据。我有两个数据集作为起点和终点。使用GoogleAPI,我想计算从原始数据集到目标数据集的方向。数据如下:

Origin(masterdata):
No xcoord  ycoord
1 109.6663 -6.897970
2 109.6584 -6.897511
3 109.6519 -6.893822
4 109.6586 -6.896936
5 109.6651 -6.897484

Destination(xystation3375)
No Long    Lat
1 109.6644 -6.889696
2 109.7008 -6.902980


key = "Google API
dataset_origin <- as.data.frame(masterdata[1:500,])
dataset_dest <- as.data.frame(xystation3375)

n = nrow(dataset_origin)

dest <- dataset_dest
k = nrow(dest)

data_od <- NULL
for(j in 1:k){
  for(i in 1:n){
    doc = mp_directions(
      origin = as.double(c(dataset_origin$xcoord[i],dataset_origin$ycoord[i])), #origin_ke-i. looping dari 1-20
      destination = as.double(c(dest$lng[j],dest$lat[j])), #destination ke_j; looping dari 1-3
      alternatives = TRUE,
      key = key,
      quiet = TRUE
    )

route = as.data.frame(mp_get_routes(doc))
route2 = cbind(route[1:7],
               rep(dataset_origin$D_NOP[i],nrow(route)),
               rep(dataset_origin$xcoord[i],nrow(route)),
               rep(dataset_origin$ycoord[i],nrow(route)),
               rep(dest$`place_name(xystation3375)`[j],nrow(route))
               )
data_od <- rbind.data.frame(data_od,route2,make.row.names = FALSE)


 }
}
那个错误有什么解决办法吗?
谢谢

如果没有谷歌api,这可以通过
geosphere
包在本地完成:

dists(1)不完整的代码(未关闭
key
string,可通过SO的代码语法突出显示进行视觉识别),请修复,并确保其与您正在使用的代码尽可能接近。(2) 你为什么要向谷歌api寻求一个简单的轴承?您可以使用
geosphere
包计算方位,而无需网络连接,而且速度会显著加快。
Error in data.frame(..., check.names = FALSE) : 
  argument is missing, with no default