| freq | R Documentation | 
Frequency table of the values of a SpatRaster. NAs are not counted unless value=NA. 
You can provide a SpatVector or additional SpatRaster to define zones for which to do tabulations.
## S4 method for signature 'SpatRaster'
freq(x, digits=0, value=NULL, bylayer=TRUE, usenames=FALSE, zones=NULL, wide=FALSE)
| x | SpatRaster | 
| digits | integer. Used for rounding the values before tabulation. Ignored if  | 
| value | numeric. An optional single value to only count the number of cells with that value. This value can be  | 
| bylayer | logical. If  | 
| usenames | logical. If  | 
| zones | SpatRaster or SpatVector to define zones for which the tabulation should be done | 
| wide | logical. Should the results by "wide" instead of "long"? | 
A data.frame with 3 columns (layer, value, count) unless bylayer=FALSE in which case adata.frame with two columns is returned (value, count). 
r <- rast(nrows=10, ncols=10)
set.seed(2)
values(r) <- sample(5, ncell(r), replace=TRUE)
freq(r)
x <- c(r, r/3)
freq(x, bylayer=FALSE)
freq(x)
freq(x, digits=1)
freq(x, digits=-1)
freq(x, value=5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.