NLSourceFromString {RNetLogo}R Documentation

Creates or appends NetLogo code from R.

Description

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

Usage

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

## 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)

[Package RNetLogo version 1.0-4 Index]