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")]