checkObject | R Documentation |
objects
slot of a
simList
objectCheck that a named object exists in the provide simList
environment slot,
and optionally has desired attributes.
checkObject(sim, name, object, layer, ...)
## S4 method for signature 'simList,ANY,ANY'
checkObject(sim, name, object, layer, ...)
## S4 method for signature 'simList,character,missing'
checkObject(sim, name, object, layer, ...)
## S4 method for signature 'missing,ANY,ANY'
checkObject(sim, name, object, layer, ...)
sim |
A |
name |
A character string specifying the name of an object to be checked. |
object |
An object. This is mostly used internally, or with layer, because it will fail if the object does not exist. |
layer |
Character string, specifying a layer name in a Raster, if the
|
... |
Additional arguments. Not implemented. |
Invisibly return TRUE
indicating object exists; FALSE
if not.
Alex Chubaty and Eliot McIntire
library()
.
sim <- simInit()
sim$a <- 1
sim$b <- list(d = 1)
sim$r <- terra::rast(terra::ext(0,2,0,2), res = 1, vals = 2)
sim$s <- c(sim$r, terra::rast(terra::ext(0,2,0,2), res = 1, vals = 3))
names(sim$s) <- c("r1", "r2") # give layer names
(checkObject(sim, name = "a")) # TRUE
(checkObject(sim, name = "b", layer = "d")) # TRUE
(checkObject(sim, name = "d")) # FALSE
(checkObject(sim, name = "r")) # TRUE
(checkObject(sim, object = sim$s)) # TRUE
(checkObject(sim, object = sim$s, layer = "r1")) # TRUE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.