Hmm, I had not tested my solution. But that used to work. But I'm
getting the same result as you do. So maybe this is a bug in ggplot2. Is
it, Hadley?
 
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.Onkelinx@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




________________________________

Van: Jason Rupert [mailto:jasonkrupert@yahoo.com] 
Verzonden: donderdag 5 februari 2009 17:44
Aan: R-help@r-project.org; ONKELINX, Thierry
CC: ggplot2@googlegroups.com
Onderwerp: RE: [R] A way to "lock down" the order of bars for ggplot
"dodged"histogram


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.ONKELINX@inbo.be> wrote:


	From: ONKELINX, Thierry <Thierry.ONKELINX@inbo.be>
	Subject: RE: [R] A way to "lock down" the order of bars for
ggplot "dodged"histogram
	To: jasonkrupert@yahoo.com, R-help@r-project.org
	Cc: ggplot2@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.Onkelinx@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-bounces@r-project.org
[mailto:r-help-bounces@r-project.org] Namens
	Jason Rupert
	Verzonden: donderdag 5 februari 2009 17:09
	Aan: R-help@r-project.org
	CC: ggplot2@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.



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]]


