Hi, been stuck on this plot for ages, and I keep getting back the statement "stat_count() can only have an x or y aesthetic" can anyone please tell me whats wrong?
fig2= ggplot(sample.bact,aes(x=i_identified_bacteria_final, y=n_isolate), stat="identity")+
geom_bar(stat = "identity",width=0.6,position = "dodge")+
scale_fill_manual(values=c("#BC3C2999","#0072B599","#7676B199"))+
geom_text(stat="count",aes(label=..count..),position=position_stack(vjust = 0.5),size=2.5)+
ylab("Number of isolates")+
xlab("Bacterial Types")+theme_bw()+
guides(fill=guide_legend(title ="Sample types"))+
geom_text(aes(label=n_isolate),position=position_dodge(width =0.6),vjust=-0.4,size=5)+
theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank(),
panel.background = element_blank(),axis.line=element_line("black"),
axis.text.y = element_text(face="bold", family = "Arial",
size=15),
title = element_text(hjust=0.5,face="bold",vjust=0.5,family = "Arial"),
text=element_text(family = "Arial",size=20
),
plot.background = element_rect("#EBEBEB"))+
facet_grid(fram~.)+
scale_y_continuous(limits = c(0, 200))+
scale_x_discrete(guide = guide_axis(angle = 45),
labels=c("E.faecalis","E.faecium","E. coli",
"K.pneumoniae",
"Salmonella spp","S.aureus"))
fig2+plot_annotation(title = "Swine Farm Isolates Summary",
theme=theme(plot.title = element_text(color="#292929",size=22,face="bold",family="Arial Black",hjust = 0.5),
plot.caption = element_text(colour = "grey50",face="italic",family = "Arial Black"),
plot.background = element_rect("#EbEBEB"),
panel.background = element_rect("#EbEBEB")))