我希望记录从一个县的SUD中心到医院的距离。代码如下:
alameda_distances <- st_distance(alameda_SUDs_centers, alameda_mediCal_hospitals) * 0.000621371
alameda_mediCal_hospitals$distance <- (as.vector(apply(alameda_distances,1, min)))
但是我在这行代码之后收到了这个错误:
alameda_mediCal_hospitals$distance <- (as.vector(apply(alameda_distances,1, min)))
Error in `[[<-.data.frame`(`*tmp*`, i, value = c(0.452148118348417, 1.15003687022296, :
replacement has 32 rows, data has 11
有什么建议吗?我在RMarkdown中使用这些库:
library(janitor)
library(sf)
library(spData)
library(sp)
library(raster)
我尝试将“NA”添加到新变量阿拉米达_mediCal_hospitals$distance
1条答案
按热度按时间anauzrmj1#
我用这个:
它返回以米为单位的距离。