I wrote the following function to create some plots:
plot <- function(date, gene, DM) {
all_concats %>% filter (date_plate_reading == date & gene_name == gene & DM_mm == DM) %>% ggplot(aes(peptide, peptide_reading_total_sem)) +
geom_point() +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
labs(x="peptide", y = "Standard mean error") +
ggtitle(gene, date)
}
the gene_name variable (gene in the function) has the following structure: gene-1, gene-2, gene-3, etc
When I create the plot, the x axis appears in alphabetical order, so gene-1, gene 10, gene 100, etc, instead of gene-1, gene2, ...
How could I reorder the x axis following a numerical order? Thanks!