| modal | R Documentation |
Compute the mode (most frequent value). For a SpatRaster this is done for each cell across layers. For a vector (or other atomic object) it is computed from the values of x and any additional arguments in ....
## S4 method for signature 'SpatRaster'
modal(x, ..., ties="first", na.rm=FALSE, filename="", overwrite=FALSE, wopt=list())
## S4 method for signature 'ANY'
modal(x, ..., ties="random", na.rm=FALSE, freq=FALSE)
x |
SpatRaster or a vector (numeric, integer, logical, character, or factor) |
... |
additional argument of the same type as |
ties |
character. Indicates how to treat ties. Either "random", "lowest", "highest", "first", or "NA" |
na.rm |
logical. If |
freq |
logical. If |
filename |
character. Output filename |
overwrite |
logical. If |
wopt |
list with named options for writing files as in |
SpatRaster, or a single value (or its frequency if freq=TRUE)
r <- rast(system.file("ex/logo.tif", package="terra"))
r <- c(r/2, r, r*2)
m <- modal(r)
modal(c(1, 2, 2, 3, 1, 2), ties="lowest")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.