我在使用 RNetLogo 包获取 R 中的代理集时遇到问题
NLCommand("setup")
who <- list()
who[[i]] <- NLGetAgentSet(c("who","xcor","ycor"), "turtles")
使用 NLGetAgetSet 函数有问题吗?我需要一些帮助。
此问题应在 rforge 提供的 RNetLogo 1.0-4 版本中修复。
用
install.packages("RNetLogo", repos="http://R-Forge.R-project.org"(
从 rforge(而不是从 CRAN(安装它。
如果您确认问题已解决,我将 CRAN 包从 1.0-3 更新到 1.0-4。
NLGetAgentSet
和 NLGetPatches
不适用于 NetLogo 6.0。(我认为这与 https://ccl.northwestern.edu/netlogo/docs/transition.html#v60 有关(。
幸运的是,这些函数只是 NLReport
的包装器。因此,您可以使用NLReport
获得代理。例如:
vars <- c("who", "xcor", "ycor")
agents <- "turtles"
reporters <- sprintf("map [x -> [%s] of x ] sort %s", vars, agents)
nlogo_ret <- RNetLogo::NLReport(reporters)
df1 <- data.frame(nlogo_ret, stringsAsFactors = FALSE)
names(df1) <- vars