NLSetPatchSet: Sets the variable value of one or more patch(es) to value(s)...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/NLSetPatchSet.R

Description

NLSetPatchSet is an easy way to set the variable value of one or more patch(es) to the value(s) of a data.frame.

Usage

1
NLSetPatchSet(patch.var, input, nl.obj=NULL)

Arguments

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.

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 patch.var.

nl.obj

(optional) A string identifying a reference to a NetLogo instance created with NLStart.

Details

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.

Value

No return value.

Author(s)

Jan C. Thiele <rnetlogo@gmx.de>

See Also

NLSetPatches, NLGetAgentSet, NLGetGraph, NLDfToList

Examples

 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)

RNetLogo documentation built on May 2, 2019, 9:29 a.m.