r - incorrect grouping in plotting longitudinal data with ggplot -
i trying plot longitudinal dataset ggplot. here example data illustrate problem. library(mass) library(ggplot2) library(dplyr) # create data dat.tx.a <- mvrnorm(n=250, mu=c(30, 20, 28), sigma=matrix(c(25.0, 17.5, 12.3, 17.5, 25.0, 17.5, 12.3, 17.5, 25.0), nrow=3, byrow=true)) dat.tx.b <- mvrnorm(n=250, mu=c(30, 20, 22), sigma=matrix(c(25.0, 17.5, 12.3, 17.5, 25.0, 17.5, 12.3, 17.5, 25.0), nrow=3, byrow=true)) dat <- data.frame(rbind(dat.tx.a, dat.tx.b)) names(dat) = c("measure.1", "measure.2", "measure.3") dat <- data.frame(subject.id=factor(1:500), tx=rep(c("a", "b"), each=250), dat) rm(dat.tx.a, dat.tx.b) dat <- reshape(dat, varying=c("measure.1", "measure.2...