powered by
Frequency table of the values of a SpatRaster. NAs are not counted.
NA
# S4 method for SpatRaster freq(x, bylayer=TRUE, ...)
SpatRaster
logical. If TRUE tabulation is done by layer
TRUE
additional arguments (none implemented)
matrix with 2 columns (value, count) or, if bylayer=TRUE three layers (layer, value, count).
bylayer=TRUE
freq
# 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