79779486

Date: 2025-09-30 20:28:29
Score: 1
Natty:
Report link

With dplyr and ggplot2, try:

ggplot(df, aes(x, y, colour = factor(class))) +
  geom_point(size = 3) +
  stat_manual(geom = "point", fun = summarise, args = vars(x = mean(x), y = mean(y)), size = 5) + # centroids
  stat_manual(geom = "segment", fun = mutate, args = vars(xend = mean(x), yend = mean(y))) # connectors

[from the examples in help("stat_manual")]

enter image description here

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: FairMiles