if (bayes_run_examples()) {
# get the probability file
data_dir <- system.file("/extdata/probs/", package = "bayesEO")
file <- list.files(data_dir)
# read the probability file into a SpatRaster
x <- terra::rast(paste0(data_dir, "/", file))
# include the labels
labels <- c("Water", "ClearCut_Burn", "ClearCut_Soil",
"ClearCut_Veg", "Forest", "Wetland")
# associate the labels to the names of the SpatRaster
names(x) <- labels
# calculate the variance
v <- bayes_variance(x)
# Plot the variance histogram
bayes_hist(v, quantile = 0.75)
}
Run the code above in your browser using DataLab