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.11

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Eliot J B

Last Published

August 17th, 2022

Functions in NetLogoR (0.3.11)

NLworldIndex

WorldMatrix indices from vector indices
NLwith

Agents with
NLall

All agents?
NLset

Set an agents variable
PxcorPycorFromCell

Patches coordinates from cells numbers
NetLogoR-package

The NetLogoR package
[[

Subsetting for worldArray class
NLcount

Count agents
NLany

Any agents?
NLdist

Distances between agents
canMove

Can the turtles move?
show,agentMatrix-method

Key base R functions for agentMatrix class
==,agentMatrix,character-method

Relational Operators
agentClasses-class

A meta class for agentMatrix and SpatialPointsDataFrame
bk

Move backward
cellFromPxcorPycor

Cells numbers from patches coordinates
agentMatrix-class

The agentMatrix class
extent,worldNLR-method

Bounding box and extent methods for NetLogoR classes
die

Kill turtles
createTurtles

Create turtles
clearPatches

Clear world's patches
agentMatrix

Create a new agentMatrix object
cbind

Combine R Objects by Rows or Columns
diffuse

Diffuse values in a world
createOTurtles

Create ordered turtles
createWorld

Create a world
coordinates,agentMatrix-method

Set spatial coordinates
downhill

Move downhill
[

Extract or Replace Parts of an Object
inRadius

Agents in radius
inCone

Agents in cone
initialize,agentMatrix-method

Initialize for agentMatrix Class
face

Face something
inspect

Inspect turtles
fargs

Function arguments
fd

Move forward
hatch

Hatch new turtles
home

Return home
layoutCircle

Layout turtles on a circle
dx

x-increment
dy

y-increment
maxNof

N agents with maximum
noPatches

No patches
noTurtles

No turtles
other

Others
isNLclass

Type of object
minOneOf

One agent with minimum
maxOneOf

One agent with maximum
maxPxcor

Maximum pxcor
minNof

N agents with minimum
nOf

N random agents
left

Rotate to the left
minPxcor

Minimum pxcor
maxPycor

Maximum pycor
oneOf

One random agent
patchAt

Patches at
patchRight

Patches on the right
minPycor

Minimum pycor
moveTo

Move to
pExist

Do the patches exist?
patch

Patches coordinates
neighbors

Neighbors patches
of

Values of an agents variable
patches

All the patches in a world
patchLeft

Patches on the left
patchHere

Patches here
patchSet

Patch set
plot.agentMatrix

Basic plot methods for agentMatrix, worldMatrix, worldArray
right

Rotate to the right
patchAhead

Patches ahead
patchDistDir

Patches at given distances and directions
randomXYcor

Random turtles coordinates
randomPycor

Random pycor
randomYcor

Random ycor
tExist

Do the turtle exist?
randomPxcor

Random pxcor
.projNowhere

Internal CRS usage
raster2world

Convert a Raster* object into a worldMatrix or worldArray object
.quickPlottables-class

quickPlot classes
spdf2turtles

From SpatialPointsDataFrame to agentMatrix
numLayers,worldArray-method

Methods for quickPlot
randomXcor

Random xcor
subHeadings

Subtract headings
sortOn

Sort agents
uphill

Move uphill
withMax

Agents with maximum
setXY

Set turtles' locations
sprout

Sprout new turtles
towards

Directions towards
worldWidth

World width
withMin

Agents with minimum
turtle

Select turtles
world2raster

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

Wrap coordinates or pixels in a torus-like fashion
turtlesOwn

New turtles variable
show,worldArray-method

Key base R functions for worldNLR classes
worldMatrix-class

The worldMatrix class
worldArray-class

The worldArray class
turtlesAt

Turtles at
turtlesOn

Turtles on
turtleSet

Create a turtle agentset
stackWorlds

Stack worlds
updateList

Update elements of a named list with elements of a second named list
worldNLR-class

The worldNLR class
turtles2spdf

From agentMatrix to SpatialPointsDataFrame
worldHeight

World height