I keep getting the error:
Error in geom_bar(subset = .(gender == "Male"), aes(y = TotalNo)) > :Error occurred in the 3rd layer. Caused by error in
setup_params()
: !stat_count()
must only have an x or y aesthetic.`
My Code:
ggplot(data = ElasmobranchSex, aes(x = TotalNo, fill = Sex, y=Quarter)) +
geom_bar(stat= 'identity')+
geom_bar(subset=.(gender=="Female")) +
geom_bar(subset=.(gender=="Male"),aes(y=quarter))+
geom_bar(stat='identity')+
scale_x_discrete(labels= quarter)
xlab("Year") +
coord_flip() +
theme(text = element_text(size=16)) +
scale_y_continuous(breaks=seq(-500,500,10),labels=abs(seq(-500,500,10))) +
scale_fill_brewer(palette="Dark2") +
facet_wrap(~Classification)`
Quarter is a column in my data quarter= is the labels 1-4 sanctioned
I am trying to created 3 facet charts next to each other (Shark,Skate,Ray) with male and female on each side of each chart. Attached is the kind of graph I am trying to produce.