I have trouble getting agent-sets in R using RNetLogo package
NLCommand("setup")
who <- list()
who[[i]] <- NLGetAgentSet(c("who","xcor","ycor"), "turtles")
Is there something wrong in using NLGetAgetSet function? I need some help.
I have trouble getting agent-sets in R using RNetLogo package
NLCommand("setup")
who <- list()
who[[i]] <- NLGetAgentSet(c("who","xcor","ycor"), "turtles")
Is there something wrong in using NLGetAgetSet function? I need some help.
This issue should be fixed in the version 1.0-4 of RNetLogo available from rforge.
Use
install.packages("RNetLogo", repos="http://R-Forge.R-project.org")
to install it from rforge (instead from CRAN).
If you confirm that the issue is fixed I will update the CRAN package from 1.0-3 to 1.0-4.
The NLGetAgentSet
and NLGetPatches
are not working with NetLogo 6.0.
(I think this is related to https://ccl.northwestern.edu/netlogo/docs/transition.html#v60).
Luckily, these functions are only wrappers for NLReport
. So you can get the agents with NLReport
instead. For example:
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