Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

freq

Frequency table


Description

Frequency table of the values of a RasterLayer.

Usage

## S4 method for signature 'RasterLayer'
freq(x, digits=0, value=NULL, useNA='ifany', progress='', ...)

## S4 method for signature 'RasterStackBrick'
freq(x, digits=0, value=NULL, useNA='ifany', merge=FALSE, progress='', ...)

Arguments

x

RasterLayer

digits

non-negative integer for rounding the cell values. Argument is passed to round

value

numeric, logical or NA. An optional single value to only count the number of cells with that value

useNA

character. What to do with NA values? Options are "no", "ifany", "always". See to table

progress

character to specify a progress bar. Choose from 'text', 'window', or ” (the default, no progress bar)

merge

logical. If TRUE the list will be merged into a single data.frame

...

additional arguments (none implemented)

Value

matrix (RasterLayer). List of matrices (one for each layer) or data.frame (if merge=TRUE) (RasterStack or RasterBrick)

See Also

Examples

r <- raster(nrow=18, ncol=36)
values(r) <- runif(ncell(r))
r[1:5] <- NA
r <- r * r * r * 5
freq(r)

freq(r, value=2)

s <- stack(r, r*2, r*3)
freq(s, merge=TRUE)

raster

Geographic Data Analysis and Modeling

v3.4-10
GPL (>= 3)
Authors
Robert J. Hijmans [cre, aut] (<https://orcid.org/0000-0001-5872-2872>), Jacob van Etten [ctb], Michael Sumner [ctb], Joe Cheng [ctb], Dan Baston [ctb], Andrew Bevan [ctb], Roger Bivand [ctb], Lorenzo Busetto [ctb], Mort Canty [ctb], Ben Fasoli [ctb], David Forrest [ctb], Aniruddha Ghosh [ctb], Duncan Golicher [ctb], Josh Gray [ctb], Jonathan A. Greenberg [ctb], Paul Hiemstra [ctb], Kassel Hingee [ctb], Institute for Mathematics Applied Geosciences [cph], Charles Karney [ctb], Matteo Mattiuzzi [ctb], Steven Mosher [ctb], Babak Naimi [ctb], Jakub Nowosad [ctb], Edzer Pebesma [ctb], Oscar Perpinan Lamigueiro [ctb], Etienne B. Racine [ctb], Barry Rowlingson [ctb], Ashton Shortridge [ctb], Bill Venables [ctb], Rafael Wueest [ctb]
Initial release
2021-05-02

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.