Jack Monpas-Huber
2010-May-14 16:52 UTC
[R] color lines by group membership in spaghetti plot
Greetings, I am new to R. Right now I'm most interested in the spaghetti plots of achievement over time by student ID associated with longitudinal analysis. How can I do a spaghetti plot of all students, but color the lines by group membership such as gender or race, and indicate this color scheme in the legend? Any advice would be much appreciated. Jack Jack B. Monpas-Huber, Ph.D. Director of Assessment & Student Information Shoreline Public Schools 18560 1st Ave NE Shoreline, WA 98155 (206) 368-4774 Office (206) 947-9926 Cell Shoreline Assessment Web site My Web site [[alternative HTML version deleted]]
Hi: Here's an example from the ggplot2 package using the Orthodont data from Pinheiro & Bates (2000): library(nlme) library(ggplot2) p <- ggplot(data = Orthodont, aes(x = age, y = distance, group = Subject, colour = Sex)) p + geom_line() ?Orthodont will give you some information about the data set. See http://had.co.nz/ggplot2/ for more information about the package. Note that the two packages have to be installed from CRAN first before you can use them. HTH, Dennis On Fri, May 14, 2010 at 9:52 AM, Jack Monpas-Huber < jack.monpas.huber@shorelineschools.org> wrote:> Greetings, > > I am new to R. Right now I'm most interested in the spaghetti plots > of achievement over time by student ID associated with longitudinal > analysis. How can I do a spaghetti plot of all students, but color > the lines by group membership such as gender or race, and indicate > this color scheme in the legend? Any advice would be much appreciated. > > Jack > > Jack B. Monpas-Huber, Ph.D. > Director of Assessment & Student Information > Shoreline Public Schools > 18560 1st Ave NE > Shoreline, WA 98155 > (206) 368-4774 Office > (206) 947-9926 Cell > Shoreline Assessment Web site > My Web site > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]