SEE EDIT BELOW
I am bar plot from a df which consists of 440 rows and is structured like so:
I then use the following code to create a barplot:
ggplot(fplot2, aes(x=SampleID, y=Abundance, fill=Taxon)) +
geom_bar(stat="identity") +
scale_fill_manual(values = Cb64k) +
theme(axis.text.x = element_text(angle=45, hjust=1)) +
coord_cartesian(expand=FALSE) +
xlab("Sample") +
ylab("Abundance") +
facet_wrap(~fplot2$Patient, scales="free_x", nrow=2, ncol=5)
Which gives me this figure:
I noticed that the patient numbers are not correct, as P_10 is second after P_1. Can I change the image so that the top row is P_1 to P_5 and the bottom row is P_6 to P_10?
Also, I noticed that for P_8 the samples are also out of order, they should be P8W0, P8W2, P8W4, P8W12, P8W14. Can I reorder that as well?
EDIT: I fixed the issue with the facet ordering by adding:
facet_wrap(~factor(fplot2$Patient,levels=c("P_1","P_2","P_3","P_4","P_5","P_6","P_7","P_8","P_9","P_10")), scales = "free_x", nrow=2, ncol=5)
But I'm not sure how to change the order of the P_8 samples