Frequency table of the values of a SpatRaster. NA
s are not counted.
# S4 method for SpatRaster
freq(x, bylayer=TRUE, ...)
SpatRaster
logical. If TRUE
tabulation is done by layer
additional arguments (none implemented)
matrix with 2 columns (value, count) or, if bylayer=TRUE
three layers (layer, value, count).
# NOT RUN {
r <- rast(nrow=10, ncol=10)
set.seed(2)
values(r) <- sample(5, ncell(r), replace=TRUE)
freq(r, FALSE)
freq(r)
x <- c(r, r/2)
freq(x, FALSE)
freq(x)
freq(round(x))
# }
Run the code above in your browser using DataLab