Description Usage Arguments Details Value Author(s) See Also Examples
NLGetPatches
is an easy way to access variables of all patches (default) or of
a subset of patches.
1 2 3 | NLGetPatches(patch.var, patchset="patches", as.matrix=FALSE,
as.data.frame=TRUE, patches.by.row=FALSE,
as.vector=FALSE, nl.obj=NULL)
|
patch.var |
A string or vector/list of strings with the names of patch variables to report. |
patchset |
(optional) A string defining which patches to request. By default, values of all patches are returned. |
as.matrix |
(optional) If this variable is |
as.data.frame |
(optional) If |
patches.by.row |
(optional) This argument has an effect only in combination with |
as.vector |
(optional) Set this argument to |
nl.obj |
(optional) A string identifying a reference to a NetLogo instance created with |
It's possible to use all the variables of a patch, which can be found in NetLogo's Agent Monitors.
Returns a data.frame (optional a list) with the variable value(s) of a patch/patches of a patchset.
One row for each patch and one column for each patch variable.
The result is sorted (like using sort patchset
in NetLogo), e.g. patches are sorted from upper left to lower right.
Jan C. Thiele <rnetlogo@gmx.de>
NLReport
,
NLGetAgentSet
,
NLGetGraph
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ## Not run:
nl.path <- "C:/Program Files/NetLogo 6.0/app"
NLStart(nl.path)
# NLLoadModel(...)
allpatches <- NLGetPatches(c("pxcor","pycor","pcolor"))
str(allpatches)
# only a subset of patches
subsetpatches <- NLGetPatches(c("pxcor","pycor","pcolor"),
"patches with [pxcor < 5]")
str(subsetpatches)
# or as a list (slightly faster):
colors.list <- NLGetPatches(c("pxcor","pycor","pcolor"),
"patches with [pxcor < 5]", as.data.frame=FALSE)
str(colors.list)
# or as a list with one list element for each patch
# (very slow!, not recommended especially for large patchsets)
colors.list2 <- NLGetPatches(c("pxcor","pycor","pcolor"),
"patches with [pxcor < 5]", as.data.frame=FALSE,
patches.by.row=TRUE)
str(colors.list2)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.