Ordering two histograms in the same plot with ggplot

I have a problem that I could not find a solution to. I have a data frame with various adjectives and participles that are in two different templates.

head(THAT_EXT_COMBINED)
          ID  PATTERN         NODE
1  HRE_721_03 THAT_EXT     accepted
2 G08_1321_01 THAT_EXT acknowledged
3   AAW_47_03 THAT_EXT acknowledged
4 G20_1490_01 THAT_EXT     alarming
5  FY8_732_02 THAT_EXT      amazing
6  HEM_128_03 THAT_EXT      amazing

str(THAT_EXT_COMBINED)
'data.frame':   1450 obs. of  3 variables:
$ ID     : Factor w/ 1450 levels "A05_253_01","A05_277_07",..: 1109 827 265 853 812 1046 369 810 214 41 ...
$ PATTERN: Factor w/ 2 levels "THAT_EXT","THAT_POST": 1 1 1 1 1 1 1 1 1 1 ...
$ NODE   : Factor w/ 201 levels "accepted","acknowledged",..: 1 2 2 6 8 8 8 10 12 15 ...

I want to build the adjectives of these two patterns while decreasing the frequency using two histograms in the same plot. The problem is that there is some overlap between them (i.e., some adjectives are found in both templates), but I just want each histogram to start with the most frequent adjective.

Here is the code that I used to sort when creating individual histograms:

THAT_EXT_COMBINED <- within(THAT_EXT_COMBINED,
                            NODE <- factor(NODE,
                                           levels=names(sort(table(NODE),
                                                             decreasing=TRUE))))

I understand why this does not work, since it combines the frequency of two patterns, but I still don't know how to solve it. I am trying to reorder () without any luck. Any ideas?

, :

graph<-ggplot(THAT_EXT_COMBINED, aes(x=NODE, fill=PATTERN)) + 
geom_histogram(binwidth=.5,  position="dodge")
graph + opts(axis.text.x = theme_blank()) + #removes text labels on x-axis
scale_y_continuous("Frequency") + 
scale_x_discrete("Adjectives",breaks=NULL)+ 
opts(title = expression("Distribution of Adjectives"))

, . - ?


, , . , , .. . , , -, PATTERN NODE. enter image description here

+5
1
library(reshape)
df <- cast(THAT_EXT_COMBINED, PATTERN ~.) 
colnames(df)[2] <- "Counts"

ggplot(df, aes(reorder(PATTERN, Counts), Counts, fill=PATTERN))
    + geom_bar(position="dodge") # + ...
0

All Articles