if (bayes_run_examples()) {
# select a file with probability values
data_dir <- system.file("/extdata/probs/", package = "bayesEO")
file <- list.files(data_dir)
# create a SpatRaster object from the file
x <- terra::rast(paste0(data_dir, "/", file))
# provide the labels
labels <- c("Water", "ClearCut_Burn", "ClearCut_Soil",
"ClearCut_Veg", "Forest", "Wetland")
# name the layers in the SpatRaster with the labels
names(x) <- labels
# calculate the variance
v <- bayes_variance(x)
# plot the variance
bayes_plot_var(v, quantile = 0.75)
}
Run the code above in your browser using DataLab