Thierry, Thank you for such a quick response. I changed the code, but I seem to get the same response. Ugh. Maybe I am missing a step. Thank you again for any feedback. Me_df<-data.frame(Data = c(1:15), Person = "Me") You_df<-data.frame(Data = c(10:20), Person = "You") Them_df<-data.frame(Data = c(15:25), Person = "Them") Group_df_tmp<-rbind(Me_df,You_df) Group_df<-rbind(Group_df_tmp,Them_df) Group_df$Person <- factor(Group_df$Person, levels = c("Them", "You", "Me")) counts <- ddply(Group_df, .(cut(Data, breaks=fullseq(range(Data), 5)), Person), nrow) names(counts) <- c("Bin", "Person", "Frequency") qplot(Person, Frequency, data = counts, fill = Person, geom="bar", stat="identity", width = 0.9, xlab="Person") + facet_grid(. ~ Bin)
--- On Thu, 2/5/09, ONKELINX, Thierry <thierry.onkel...@inbo.be> wrote: From: ONKELINX, Thierry <thierry.onkel...@inbo.be> Subject: RE: [R] A way to "lock down" the order of bars for ggplot "dodged"histogram To: jasonkrup...@yahoo.com, R-help@r-project.org Cc: ggpl...@googlegroups.com Date: Thursday, February 5, 2009, 10:17 AM Dear Jason, Convert Person to a factor with the levels in the order that you want. Group_df$Person <- factor(Group_df$Person, levels = c("Them", "You", "Me")) HTH, Thierry ---------------------------------------------------------------------------- ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -----Oorspronkelijk bericht----- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Jason Rupert Verzonden: donderdag 5 februari 2009 17:09 Aan: R-help@r-project.org CC: ggpl...@googlegroups.com Onderwerp: [R] A way to "lock down" the order of bars for ggplot "dodged"histogram It appears that ggplot reorder the data for a "dodged" histogram based on whether or not a specific variable has a value in the first bin. I would like to be able to absolutely force the order of the variables in the bin. For example, say I have three variables Me, You, and Them. Me_df<-data.frame(Data = c(1:15), Person = "Me") You_df<-data.frame(Data = c(10:20), Person = "You") Them_df<-data.frame(Data = c(15:25), Person = "Them") Group_df_tmp<-rbind(Me_df,You_df) Group_df<-rbind(Group_df_tmp,Them_df) counts <- ddply(Group_df, .(cut(Data, breaks=fullseq(range(Data), 5)), Person), nrow) names(counts) <- c("Bin", "Person", "Frequency") qplot(Person, Frequency, data = counts, fill = Person, geom="bar", stat="identity", width = 0.9, xlab="Person") + facet_grid(. ~ Bin) However, I absolutely must have the bar order be Them, You, Me. Is there a to fix the order of the bars so that they are always in the Them, You, Me order? Thank you again for any feedback you can provide. [[alternative HTML version deleted]] Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. [[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.