I am making a bar graph showing the percentage of different types of victim items returned to the nest.
My data is as follows:
Prey <- c(rep("Bird", 12), rep("Lizard", 3), rep("Invertebrate", 406))
Type <- c(rep("Unknown bird", 12), rep("Skink", 2), rep("Gecko", 1),
rep("Unknown Invertebrate", 170), rep("Beetle", 1),
rep("Caterpillar", 3), rep("Grasshopper", 3), rep("Huhu grub", 1),
rep("Moth", 34), rep("Praying mantis", 1), rep("Weta", 193))
Preydata <- data.frame(Prey,Type)
ggplot(Preydata, aes(x = Prey, y = (..count..)/sum(..count..))) +
scale_y_continuous(labels = percent_format()) +
geom_bar(aes(fill = Type), position = "dodge")
My schedule is as follows.

I would like all the widths of the type columns to be the same, but when I change the width under geom_bar, it changes the width of the "victim" strip. When I try to use the following:
ggplot(Preydata, aes(x = as.numeric(interaction(Prey, Type)),
y = (..count..)/sum(..count..))) +
scale_y_continuous(labels = percent_format()) +
geom_bar(aes(fill = Type), position = "dodge")
My bars are no longer in the correct order or grouped by "Prey". Is there any way to change this?
