Learn R Programming

NetLogoR (version 0.3.9)

isNLclass: Type of object

Description

Report TRUE if the agents is of the class tested, report FALSE otherwise.

Usage

isNLclass(agents, class)

# S4 method for matrix,character isNLclass(agents, class)

Arguments

agents

Matrix (ncol = 2) with the first column pxcor and the second column pycor representing the patches coordinates, or

AgentMatrix object representing the moving agents.

class

Character. Can take one of the following options to define the class: "agent", "agentset", "patch", "patchset". "turtle" or "turtleset".

Value

Logical. TRUE if agents is of the class tested.

Details

Careful! The class tested does not correspond to actual R classes.

agents is "patch" if it is a matrix (ncol = 2) with the first column pxcor and the second column pycor with only one row. agents is "patcheset" if the matrix has more than one row.

agents is "turtle" if it is an agentMatrix containing only one turtle. agents is "turtleset" if the agentMatrix contains more than one turtle.

agents is "agent" if it is either "patch" or "turtle". agents is "agentset" if it is either "patcheset" or "turtleset".

References

Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL.

See Also

https://ccl.northwestern.edu/netlogo/docs/dictionary.html#is-of-type

Examples

Run this code
# NOT RUN {
w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4)
t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10),
                    heading = sample(1:3, size = 10, replace= TRUE))
isNLclass(agents = patches(w1), class = "patch")
isNLclass(agents = patches(w1), class = "patcheset")
isNLclass(agents = t1, class = "agentset")
isNLclass(agents = t1, class = "turtleset")


# }

Run the code above in your browser using DataLab