Hi Dennis, It is similar to what I was trying to achieve. Is there a way to show the grouped time courses as separate facets. So in lattice, the time courses would be conditioned on Ab status and subject name at the same time.
Thanks. George From: "Dennis Murphy" <djmu...@gmail.com> To: "George Chen" <glc...@stanford.edu> Cc: r-help@r-project.org Sent: Saturday, May 8, 2010 9:38:07 PM Subject: Re: [R] Is it possible to rearrange the facets in ggplot while keeping everything else the same? Hi: I'm not sure this is what you're looking for, but it sounds to me that you want to group subjects with the same Ab value together. If that's the case, then try this; your test data is called df ... df$Subject <- factor(df$Subject) p2 <- ggplot(df, aes(x = Day, y = Value, colour = Subject)) p2 + geom_point() + geom_line(aes(group = Subject)) + facet_grid(Variable ~ Ab) HTH, Dennis On Sat, May 8, 2010 at 6:56 PM, George Chen < glc...@stanford.edu > wrote: Hello, First, ggplot2 is great! Second, sorry for the basic nature of my question. I have data in the form of a melt table like this: Subject Day Ab Variable Value 1 1 Yes A 3 1 3 Yes A 5 1 5 Yes A 7 2 1 No A 2 2 3 No A 4 2 5 No A 6 3 1 Yes A 1 3 3 Yes A 3 3 5 Yes A 5 4 1 No A 4 4 3 No A 6 4 5 No A 8 1 1 Yes B 3 1 3 Yes B 5 1 5 Yes B 7 2 1 No B 2 2 3 No B 4 2 5 No B 6 3 1 Yes B 1 3 3 Yes B 3 3 5 Yes B 5 4 1 No B 4 4 3 No B 6 4 5 No B 8 1 1 Yes C 3 1 3 Yes C 5 1 5 Yes C 7 2 1 No C 2 2 3 No C 4 2 5 No C 6 3 1 Yes C 1 3 3 Yes C 3 3 5 Yes C 5 4 1 No C 4 4 3 No C 6 4 5 No C 8 The table goes on like this for another 11 subjects. I can plot a 3 row (A,B,C) x 4 column (Sub 1,2,3,4) grid of time courses with the y labels for the facets being 1,2,3,4 and the x labels for the facets being A,B,C. qplot(Day,Value,data="data above") + facet_grid(Variable~Subject, scales="free_y") But, how do I rearrange the columns so that all the Yeses to Ab are together and the Nos to Ab are together while keeping the same labeling? Thanks in advance. George Chen ______________________________________________ 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]] ______________________________________________ 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.