Learn R Programming

⚠️There's a newer version (1.0.5) of this package.Take me there.

NetLogoR

Build and run spatially explicit agent-based models in R

NetLogoR is an R package to build and run spatially explicit agent-based models using only the R platform (Bauduin et al., 2019). It follows the same framework as NetLogo (Wilensky, 1999) and is a translation in R language of the structure and functions of NetLogo (NetLogo primitives). NetLogoR provides new R classes to define model agents and functions to implement spatially explicit agent-based models in the R environment. This package allows benefiting of the fast and easy coding phase from the highly developed NetLogo's framework, coupled with the versatility, power and massive resources of the R software.

Getting Started

Examples of three models (Ants, Butterfly (Railsback and Grimm, 2012) and Wolf-Sheep-Predation) written using NetLogoR are available. The NetLogo code of the original version of these models is provided alongside. A programming guide inspired from the NetLogo Programming Guide and a dictionary of NetLogo primitives equivalences are also available. A model simulating the wolf life cycle written using NetLogoR has been published (Bauduin et al., 2020) with the (code available on GitHub).

Installing NetLogoR

From CRAN

install.packages("NetLogoR")

From GitHub

#install.packages("devtools")
devtools::install_github("PredictiveEcology/NetLogoR")

Getting help

We have created a Google group for users to get help implementing their models using the package. Please see the discussions at https://groups.google.com/g/netlogor.

Copy Link

Version

Install

install.packages('NetLogoR')

Monthly Downloads

290

Version

0.3.9

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Eliot J B

Last Published

October 19th, 2021

Functions in NetLogoR (0.3.9)

NLdist

Distances between agents
NLset

Set an agents variable
NLwith

Agents with
NLcount

Count agents
NetLogoR-package

The NetLogoR package
NLworldIndex

WorldMatrix indices from vector indices
PxcorPycorFromCell

Patches coordinates from cells numbers
extent,worldNLR-method

Bounding box and extent methods for NetLogoR classes
[[

Subsetting for worldArray class
canMove

Can the turtles move?
NLall

All agents?
bk

Move backward
dx

x-increment
agentClasses-class

A meta class for agentMatrix and SpatialPointsDataFrame
agentMatrix-class

The agentMatrix class
cellFromPxcorPycor

Cells numbers from patches coordinates
diffuse

Diffuse values in a world
downhill

Move downhill
cbind

Combine R Objects by Rows or Columns
==,agentMatrix,character-method

Relational Operators
dy

y-increment
NLany

Any agents?
show,agentMatrix-method

Key base R functions for agentMatrix class
createWorld

Create a world
agentMatrix

Create a new agentMatrix object
die

Kill turtles
minPycor

Minimum pycor
clearPatches

Clear world's patches
[

Extract or Replace Parts of an Object
hatch

Hatch new turtles
home

Return home
moveTo

Move to
createTurtles

Create turtles
createOTurtles

Create ordered turtles
coordinates,agentMatrix-method

Set spatial coordinates
face

Face something
inCone

Agents in cone
inRadius

Agents in radius
patchSet

Patch set
patchRight

Patches on the right
maxOneOf

One agent with maximum
initialize,agentMatrix-method

Initialize for agentMatrix Class
other

Others
patches

All the patches in a world
numLayers,worldArray-method

Methods for quickPlot
pExist

Do the patches exist?
plot.agentMatrix

Basic plot methods for agentMatrix, worldMatrix, worldArray
maxPxcor

Maximum pxcor
.projNowhere

Internal CRS usage
left

Rotate to the left
maxNof

N agents with maximum
patchAhead

Patches ahead
randomPxcor

Random pxcor
minOneOf

One agent with minimum
patch

Patches coordinates
minPxcor

Minimum pxcor
.quickPlottables-class

quickPlot classes
fargs

Function arguments
noPatches

No patches
subHeadings

Subtract headings
uphill

Move uphill
tExist

Do the turtle exist?
withMax

Agents with maximum
fd

Move forward
inspect

Inspect turtles
isNLclass

Type of object
minNof

N agents with minimum
maxPycor

Maximum pycor
layoutCircle

Layout turtles on a circle
sprout

Sprout new turtles
stackWorlds

Stack worlds
of

Values of an agents variable
oneOf

One random agent
patchAt

Patches at
randomXcor

Random xcor
patchDistDir

Patches at given distances and directions
randomYcor

Random ycor
setXY

Set turtles' locations
show,worldArray-method

Key base R functions for worldNLR classes
turtlesAt

Turtles at
nOf

N random agents
updateList

Update elements of a named list with elements of a second named list
turtlesOwn

New turtles variable
worldMatrix-class

The worldMatrix class
neighbors

Neighbors patches
worldNLR-class

The worldNLR class
turtlesOn

Turtles on
turtle

Select turtles
towards

Directions towards
turtleSet

Create a turtle agentset
turtles2spdf

From agentMatrix to SpatialPointsDataFrame
patchHere

Patches here
patchLeft

Patches on the left
worldHeight

World height
worldArray-class

The worldArray class
noTurtles

No turtles
right

Rotate to the right
raster2world

Convert a Raster* object into a worldMatrix or worldArray object
randomXYcor

Random turtles coordinates
spdf2turtles

From SpatialPointsDataFrame to agentMatrix
sortOn

Sort agents
randomPycor

Random pycor
wrap

Wrap coordinates or pixels in a torus-like fashion
world2raster

Convert a worldMatrix or worldArray object into a Raster* object
worldWidth

World width
withMin

Agents with minimum