Learn R Programming

shinyscholar (version 0.2.5)

plot_hist: Extract values from a raster to produce a histogram

Description

Called by the plot_hist module in the example app and extracts values from a raster image, returning a histogram of density

Usage

plot_hist(raster, bins, logger = NULL)

Value

a list of class histogram

Arguments

raster

SpatRaster object

bins

The number of breaks in the histogram

logger

Stores all notification messages to be displayed in the Log Window. Insert the logger reactive list here for running in shiny, otherwise leave the default NULL

Author

Simon Smart simon.smart@cantab.net

Examples

Run this code
if (check_suggests(example = TRUE)) {
  raster <- terra::rast(ncol = 8, nrow = 8)
  raster[] <- sapply(1:terra::ncell(raster), function(x){
    rnorm(1, ifelse(x %% 8 != 0, x %% 8, 8), 3)})
  histogram <- plot_hist(raster, bins = 10)
} else {
  message('reinstall with install.packages("shinyscholar", dependencies = TRUE)
  to run this example')
}

Run the code above in your browser using DataLab