NLworldIndex {NetLogoR}R Documentation

WorldMatrix indices from vector indices

Description

Convert vector indices or ⁠Raster*⁠ cell numbers into worldMatrix indices.

Usage

NLworldIndex(world, cellNum)

## S4 method for signature 'worldMatrix,numeric'
NLworldIndex(world, cellNum)

Arguments

world

WorldMatrix or worldArray object.

cellNum

Integer. Vector of cells number.

Value

Numeric. Vector of worldMatrix indices.

Author(s)

Eliot McIntire

Examples

if (requireNamespace("raster", quietly = TRUE)) {
  w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9, data = 1:100)
  w1Ras <- world2raster(w1)
  index <- 24
  pxpy <- PxcorPycorFromCell(world = w1, cellNum = index)

  rasValue <- as.integer(unname(w1Ras[index]))
  # Not correct index:
  identical(w1[index], rasValue)

  # Correct index
  identical(w1[NLworldIndex(w1, index)], rasValue)
}


[Package NetLogoR version 1.0.5 Index]