Last chance! 50% off unlimited learning
Sale ends in
NLGetPatches
is an easy-to-use way to access variables of all patches (default) or of
an subset of patches.NLGetPatches(patch.var, patchset="patches", as.matrix=FALSE,
as.data.frame=FALSE, df.col.names=NULL,
nl.obj=NULL)
TRUE
, the function will return the result as a matrix representing the NetLogo world.
(Only available if you don't change the argument patchset
, i.e. if you request the all patches/the whole worTRUE
(and patch.var is a list or vector) the function will return a data.frame instead a list. Default is FALSE
which returns a list.
Tip: If you want to get more than one patch variable (patch.var is a list or vas.data.frame=TRUE
you can define the names of the columns of the returned data.frame via this parameter.
Input should be a vector containing the names as strings in the same order as the submitted reporters.NLStart
.NLReport
,
NLGetAgentSet
,
NLGetGraph
NLStart("C:/Program Files/NetLogo 4.1.3")
allpatches <- NLGetPatches(c("pxcor","pycor","pcolor"))
subsetpatches <- NLGetPatches(c("pxcor","pycor","pcolor"),
"patches with [pxcor < 5]")
# it's equivalent to (but unsorted):
# subsetpatches <- NLReport("[(list pxcor pycor pcolor)]
# of patches with [pxcor < 5]")
# and
# subsetpatches <- NLGetAgentSet(c("pxcor","pycor","pcolor"),
# "patches with [pxcor < 5]")
Run the code above in your browser using DataLab