agentMatrix-class: The 'agentMatrix' class

Description Author(s) Examples

Description

The agentMatrix class

Author(s)

Eliot McIntire

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
newAgent <- new("agentMatrix",
      coords = cbind(pxcor = c(1, 2, 5), pycor = c(3, 4, 6)),
      char = letters[c(1, 2, 6)],
      nums2 = c(4.5, 2.6, 2343),
      char2 = LETTERS[c(4, 24, 3)],
      nums = 5:7)

# compare speeds -- about 5x faster
if(require(microbenchmark)) {
  microbenchmark(times = 499,
    spdf = {SpatialPointsDataFrame(
      coords = cbind(pxcor = c(1, 2, 5), pycor = c(3, 4, 6)),
      data = data.frame(
          char = letters[c(1, 2, 6)],
          nums2 = c(4.5, 2.6, 2343),
          char2 = LETTERS[c(4, 24, 3)],
          nums = 5:7))},
    agentMat = {agentMatrix(
        coords = cbind(pxcor = c(1, 2, 5),
        pycor = c(3, 4, 6)),
        char = letters[c(1, 2, 6)],
        nums2 = c(4.5, 2.6, 2343),
        char2 = LETTERS[c(4, 24, 3)],
        nums = 5:7)},
    agentMatDirect = {new("agentMatrix",
        coords = cbind(pxcor = c(1, 2, 5),
        pycor = c(3, 4, 6)),
        char = letters[c(1, 2, 6)],
        nums2 = c(4.5, 2.6, 2343),
        char2 = LETTERS[c(4, 24, 3)],
        nums = 5:7)})
}

NetLogoR documentation built on July 10, 2021, 5:06 p.m.