NLSourceFromString: Creates or appends NetLogo code from R.

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

View source: R/NLSourceFromString.R

Description

NLSourceFromString is a way to create/append a NetLogo model's source code dynamically from R.

Usage

1
NLSourceFromString(..., append.model=TRUE, nl.obj=NULL)

Arguments

...

An undefined number of strings containing NetLogo model source code to be printed into the procedures tab. Line breaks within a string can be represented as \n.

append.model

(optional) Determines whether existing code in the procedures tab (i.e. a loaded model) will be appended by the new code or will be replaced. By default, all existing code will be appended.

nl.obj

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

Details

This function only works with NetLogo instances with GUI. It doesn't work in headless mode.

Value

No return value.

Author(s)

Jan C. Thiele <rnetlogo@gmx.de>

See Also

NLReport, NLGetAgentSet, NLGetGraph, NLDfToList

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
nl.path <- "C:/Program Files/NetLogo 6.0/app"
NLStart(nl.path)
setup <- "to setup\n ca\n crt 10\nend \n"
go <- "to go\n ask turtles [\n  set xcor random-xcor\n  
       set ycor random-ycor\n ]\nend \n"
reporter1 <- "to-report noturtles\n report count turtles\n end \n"
NLSourceFromString(setup,go,reporter1, append.model=FALSE)
NLCommand("setup")
NLCommand("go")
noturtles <- NLReport("noturtles")
print(noturtles)

## End(Not run)

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