Learn R Programming

RNetLogo (version 1.0-4)

NLDfToList: Transforms a data.frame into a NetLogo list or multiple NetLogo lists (one for each column of the data.frame).

Description

NLDfToList pushes the values of a data.frame into NetLogo lists. The column names of the data.frame are used as names for the NetLogo lists (but the lists must already exist in the current NetLogo model).

Usage

NLDfToList(in.data.frame, nl.obj=NULL)

Arguments

in.data.frame

The data.frame to fill the NetLogo lists.

nl.obj

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

Value

No return value.

Details

Remember: There must be lists in the NetLogo model with the names of the columns of the submitted data.frame.

See Also

NLDoCommand, NLDoCommandWhile, NLReport

Examples

Run this code

NLStart("C:/Program Files/NetLogo 6.0/app")
df1 <- data.frame(x=c(1,2,3,4),y=c(5,6,7,8))
# the current NetLogo model must have two variables ('x' and 'y')
# add the variables
NLSourceFromString("globals [x y]", append.model=FALSE)
# set the variables to the data.frame
NLDfToList(df1)

Run the code above in your browser using DataLab