Creates ggplot2 visualizations of BORG diagnosis + CV results.
Usage
# S3 method for class 'borg_result'
autoplot(
object,
type = borg_result_plot_types(),
fold = 1,
data = NULL,
coords = NULL,
raster = NULL,
time = NULL,
groups = NULL,
...
)Arguments
- object
A
borg_resultobject fromborg().- type
Character. Plot type:
"split"(default),"risk","spatial","temporal", or"groups".- fold
Integer. Which fold to plot. Default: 1.
- data
Optional data frame (or sf/SpatVector) for spatial plots. Required for
type = "spatial"to obtain coordinates.- coords
Character vector of coordinate column names. Required for
type = "spatial"whendatais a plain data.frame.- raster
Optional
terra::SpatRaster. When provided withtype = "spatial", the first layer is rendered as a background map behind the fold points. Requires the tidyterra package.- time
Character name of the time column in
data, or a vector of time values (length =nrow(data)). Required fortype = "temporal".- groups
Character name of the grouping column in
data, or a vector of group labels. Required fortype = "groups".- ...
Additional arguments (currently unused).
Details
Requires the ggplot2 package. For spatial plots, the sf package is recommended for proper map projections.
Examples
# \donttest{
if (requireNamespace("ggplot2", quietly = TRUE)) {
set.seed(42)
d <- data.frame(x = runif(100), y = runif(100), z = rnorm(100))
result <- borg(d, coords = c("x", "y"), target = "z")
ggplot2::autoplot(result)
ggplot2::autoplot(result, type = "spatial", data = d, coords = c("x", "y"))
}
# }