Qiime2R: Rearranging x-axis in taxa_barplot

Hi!
I am inexperienced in R and I am trying to rearrange my x-axis according to the sampling dates (27-10-20, 5-11-20, 7-1-21, 4-2-21) for each category (location; LP and T) using taxa_barplot function in Qiime2R. This is the code that I used (according to the tutorial):
library (tidyverse)
library (qiime2R)

metadata<-read_q2metadata(“sample-metadata.tsv”)
SVs<-read_qza(“table-with-phyla-no-mitochondria-no-chloroplast.qza”)$data
taxonomy<-read_qza(“taxonomy.qza”)$data %>% parse_taxonomy()

taxasums<-summarize_taxa(SVs, taxonomy)$Genus

taxa_barplot(taxasums, metadata, “location”)

ggsave(“barplot.pdf”, height=4, width=8, device=“pdf”) # save a PDF 4 inches by 8 inches

And this is the metadata file: sample-metadata.tsv (397 Bytes)

This is the current barplot that I have:
image

Any help will be much appreciated! Thank you so much.

In ggplot, the you can control the order of the samples on the X by making them a factor.
You could do something like this:

metadata<-
read_q2metadata(“sample-metadata.tsv”) %>%
arrange(YourColumnWithDate) %>% # this sorts the table by the indicated column
mutate(SampleID=as.factor(SampleID, levels=SampleID)

Hi @jbisanz ,
Thank you for your reply.
However, I encountered this error:
image

And this is the new metadata file: sample-metadata.txt (390 Bytes)