Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/NLSetPatchSet.R
NLSetPatchSet
is an easy way to set the variable value of one or more patch(es) to the value(s) of a data.frame.
1 | NLSetPatchSet(patch.var, input, nl.obj=NULL)
|
patch.var |
This argument gives the name of the patch variable as a string which should be set to the values of the third (for NetLogo 2D) or fourth column (for NetLogo 3D) of the data.frame submitted in |
input |
A data.frame with columns giving the coordinates of a patch and the values for the patch variable to be changed. For conventional 2D NetLogo there has to be a pxcor and a pycor column , for NetLogo 3D there has to be a pxcor, a pycor, and a pzcor column. name of the column that contains the new values for the patch variable has to be equal to the argument |
nl.obj |
(optional) A string identifying a reference to a NetLogo instance created with |
This function is used to update one patch variable for patches identified by their pxcor, pycor (and pzcor in case of NetLogo 3D) values based on values given in a data.frame.
No return value.
Jan C. Thiele <rnetlogo@gmx.de>
NLSetPatches
,
NLGetAgentSet
,
NLGetGraph
,
NLDfToList
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## Not run:
nl.path <- "C:/Program Files/NetLogo 6.0/app"
NLStart(nl.path)
# NLLoadModel(...)
# for NetLogo 2D:
input <- NLGetPatches(c("pxcor","pycor","pcolor"))
str(input)
# for NetLogo 3D:
input <- NLGetPatches(c("pxcor","pycor","pzcor","pcolor"))
str(input)
input$pcolor <- floor(abs(rnorm(nrow(input))*100))
patch.var <- "pcolor"
NLSetPatchSet(patch.var, input)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.