0
我已经使用mat2listw{spdep}
创建了一个权重列表对象,我稍后将在空间回归中使用它。我想从这个权重列表对象中检索用于创建它的多边形的ID。 是否有可能从对象中恢复此信息?从权重列表对象spdep中提取空间ID R
这里是一个重复的例子:
library(spdep)
library(UScensus2000tract)
# load data
data("oregon.tract")
# get coordinates of centroids
coords <- coordinates(oregon.tract)
# calculate a simple distance matrix between coordinates
d <- dist(coords)
d <- as.matrix(d)
# Calculate Spatial weights Matrix (travel time)
my_weights <- mat2listw(d, row.names = row.names(oregon.tract))
# Now I'd like to extract from my_weights the polygon ids
这可能工作: - '属性(my_weights)$ region.id' – ahly
@ahly,它完美的作品。请发表您的评论作为答案,以便我可以接受它。谢谢。 –