I am attempting to make a bar graph figure in ggplot2 with all bars having an equal width regardless if there is data present for a particular variable combination. This question is quite similar to the one found here "Consistent width for geom_bar in the event of missing data"; however, I do not have a variable mapped to the y-axis, but rather I am doing a count of the number of times a specific combination of variables occurs.
Does anyone know of a way to work around this? Also, in my original "actual" dataset, I have two variables to account for in facet_wrap, rather than one. Would answers differ when including this extra variable?
The code I have worked out currently is giving me uneven bar widths:
library(ggplot2) ggplot(dat, aes(Subjective_Assessment, fill=pts))+geom_bar(position="dodge")+ facet_wrap(~background)+ labs(y="Count")
Example Bar graph resulting in uneven bar widths
species background pts Subjective_Assessment
Species_1 State_1 Factor_1 Good
Species_2 State_1 Factor_1 Good
Species_3 State_1 Factor_1 Good
Species_4 State_1 Factor_1 Good
Species_1 State_1 Factor_2 Poor
Species_2 State_1 Factor_2 Poor
Species_3 State_1 Factor_2 Moderate
Species_4 State_1 Factor_2 Poor
Species_1 State_1 Factor_3 Moderate
Species_2 State_1 Factor_3 Moderate
Species_3 State_1 Factor_3 Moderate
Species_4 State_1 Factor_3 Poor
Species_1 State_2 Factor_1 Good
Species_2 State_2 Factor_1 Good
Species_3 State_2 Factor_1 Good
Species_4 State_2 Factor_1 Good
Species_1 State_2 Factor_2 Moderate
Species_2 State_2 Factor_2 Moderate
Species_3 State_2 Factor_2 Moderate
Species_4 State_2 Factor_2 Moderate
Thanks in advance for your help.