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

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

Examples

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")
#> [1] FALSE
isNLclass(agents = patches(w1), class = "patcheset")
#> [1] FALSE
isNLclass(agents = t1, class = "agentset")
#> [1] TRUE
isNLclass(agents = t1, class = "turtleset")
#> [1] TRUE