Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

nldoc_network

Create NetLogo procedure network


Description

Create NetLogo procedure network

Usage

nldoc_network(modelfiles)

Arguments

modelfiles

vector of filepaths to model files

Details

Reads model code from the provided model files. The procedure identifies NetLogo procedures and searches for procedure calls within the code. From this data, an igraph network is created and returned. This network can be used to plot the model procedure network and identify model components.

Value

network of model procedures (igraph)

Examples

## Not run: 

# List model files (.nls subfiles are also supported)
modelfiles <- c("https://raw.githubusercontent.com/nldoc/nldoc_pg/master/WSP.nlogo",
                "https://raw.githubusercontent.com/nldoc/nldoc_pg/master/WSP.nls")

# Determine the function network:
nw <- nldoc_network(modelfiles)

# Determine communities within the network and plot using Igraph package:
library(igraph)
com <- walktrap.community(nw)
V(nw)$community <- com$membership
rain <- rainbow(14, alpha=.5)
V(nw)$color <- rain[V(nw)$community]

plot(nw,
     edge.arrow.size=.2,
     vertex.label.color="black",
     vertex.label.dist=1,
     vertex.size=5,
     edge.curved=0,
     vertex.label.cex=.5,
     layout=layout_with_fr(nw, niter = 2000))

# Interactive plot using igraph::tkplot
tkplot(nw, layout=layout_with_fr(nw, niter = 2000))

## End(Not run)

nlrx

Setup, Run and Analyze 'NetLogo' Model Simulations from 'R' via 'XML'

v0.4.2
GPL-3
Authors
Jan Salecker [aut, cre] (<https://orcid.org/0000-0002-9000-4229>), Marco Sciaini [aut] (<https://orcid.org/0000-0002-3042-5435>), Marina Papadopoulou [rev] (Marina reviewed the package for ropensci, see <https://github.com/ropensci/software-review/issues/262>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.