I have a set of data that looks basically like this (not real data):
Group Color RelFreq1
Asparagopsis 1 30
Asparagopsis 2 30
Asparagopsis 3 40
Cyano 1 100
Dichtomaria 1 20
Dichtomaria 2 40
Group Tissue RelFreq2
Asparagopsis 5 20
Asparagopsis 6 50
Asparagopsis 7 30
Cyano 0 100
Dichtomaria 5 60
Dicthomaria 8 40
With Several groups and two sets of variables. (color ranges from 1-3, Tissue ranges from 0,5-8). Both sets of variables have calculated relative frequencies for each value. I have made stacked bar graphs for each separately (real data here): graph 1 (Color):
CbAg4_stacked <- ggplot(ColorbyAg4, aes(x=AlgaeGenus, y=RelFreqC, fill=Color))+geom_bar(stat="identity")
CbAg4_stacked <- CbAg4_stacked + ylab("Relative Frequency")
graph 2 (Tissue):
TbAg_stacked <- ggplot(TissuebyAg, aes(x=AlgaeGenus, y=RelFreqT, fill=Tissue))+geom_bar(stat="identity")
TbAg_stacked <- TbAg_stacked + ylab("Relative Frequency")
(graphs are not perfect of course because they're not how I want the finished product yet)
I would like to have them merged into one plot, with the two stacked bars for each group next to each other. (ex: for Asparagopsis, two stacked bars: one for color, one for tissue). I'll make them different colors too, but what I need help with is getting the two sets of data into the same plot. I can merge the data into one dataframe, but how do I do the graphing?
I've been using ggplot2, but I'm open to using something else if it provides a better solution. ggplot(dfm, aes(x=AlgaeGenus, y=?? How can I specify both RelFreq1 and RelFreq2? I tried c(RelFreq1, RelFreq2) and it didn't like that. I'll also need to give it multiple things for "fill=", both Color and Tissue.
Any advice? Is this possible? Both y axes are the same scale (relative frequencies out of 100), so it seems like there should be a way, but I can't figure it out.