ggforma简体中文

Compare service profiles with a radar chart

Two sites have four indicators in two reporting periods. Each spoke uses its own units and keeps the same scale in both panels.

Two sites have four indicators in two reporting periods. Each spoke uses its own units and keeps the same scale in both panels.
PNG · SVG · PDF · Open in the gallery

Give ggradar() one row per site and period. The table passed to limits sets the lower and upper bounds in each indicator's original units. Use facet to compare periods. The dashed outline and diamonds mark targets, and the band shows benchmark ranges.

library(ggforma)
library(ggplot2)

# Example indicators for two sites and two reporting periods.
scores <- data.frame(
  site = rep(c("North", "South"), 2),
  period = rep(c("Baseline", "Follow-up"), each = 2),
  coverage = c(62, 72, 87, 78),
  tests = c(540, 690, 910, 780),
  timely = c(66, 58, 84, 72),
  visits = c(240, 170, 310, 268)
)
scales <- data.frame(
  axis = c("Coverage (%)", "Tests", "On time (%)", "Visits"),
  lower = 0, upper = c(100, 1200, 100, 400)
)
names(scores)[3:6] <- scales$axis
axes <- scales$axis
targets <- c("Coverage (%)" = 75, Tests = 780, "On time (%)" = 75, Visits = 260)
bands <- transform(scales, lower = c(63, 620, 60, 200), upper = c(83, 940, 89, 320))

radar <- ggradar(scores, vars = all_of(axes), group = site, facet = period,
                 limits = scales, reference = targets, intervals = bands,
                 grid = "circle", fill = FALSE) +
  labs(title = "How service profiles changed", colour = NULL,
       caption = "Dashed outline and diamonds mark targets. Shading shows benchmark ranges.")

png_device <- function(filename, width, height, bg = "white", ...) {
  ragg::agg_png(filename, width = width, height = height, units = "in",
                res = 144, background = bg)
}

render_example <- function(file, device = png_device) {
  ggsave(file, radar, width = 9.1, height = 4.35, units = "in",
         device = device, bg = "white")
}

png.file <- file.path(tempdir(), "radar-profiles.png")
render_example(png.file)
png.file

Download R script

Compare each indicator along its own spoke. The area changes with the order and scale of the spokes. The shaded band summarizes separate indicator ranges.