首页 > 解决方案 > R:如何在 aw_weight() 函数中添加变量作为参数?

问题描述

我正在尝试在 R 的 aw_weight() 函数中传递一个变量。(https://www.rdocumentation.org/packages/areal/versions/0.1.7/topics/aw_weight

例如:

aw_weight(intersect, areaVar = "area", totalVar = "totalArea", areaWeight = "areaWeight")

而不是将变量传递给 areaWeight 而不是字符串:

for (n in c("1","2","3")){
   aw_weight(intersect, areaVar = "area", totalVar = "totalArea", areaWeight = paste0(areaWeight, n))
}

但这不起作用。它将“ areaWeight ”列命名为“paste0(areaWeight, n)”,而不是我想要的“areaWeight1”、“areaWeight2”、“areaWeight3”。

提前感谢您的回答!!

标签: r

解决方案


推荐阅读