structure diagram where each members of group are connected to center and all cluster grand center in r
问题 I am trying to create a structure diagram from the data like the following: mydf <- data.frame ( group = rep (1:5, each = 20), z = rnorm (20, 10, 1), x = c(rnorm (20, 2, 0.5), rnorm (20, 2, 0.5), rnorm (20, 9, 0.5), rnorm (20, 9, 0.5),rnorm (20, 5, 0.5)), y = c(rnorm (20, 2, 0.5), rnorm (20, 9, 0.5), rnorm (20, 2, 0.5), rnorm (20, 9, 0.5), rnorm (20, 2, 0.5))) means <- aggregate(. ~ group, data = mydf, mean) gmx <-mean (mydf$x) gmy <- mean (mydf$y) library(ggplot2) ggplot(mydf, aes(x, y)) +