I'm trying to plot a boxplot by ggplot2
and it sorts the boxes in alphabetical order, but I want to change their order. How can I do that?
Thanks for any help.
Here is my code:
mydata <- data.frame(DRG=c(12,23,15,60,2),
XPA=c(30,25,55,70,63),
SHO=c(22,15,34,23,14),
ALA=c(120,95,113,126,103))
row.names(mydata) <- c("sample1","sample2","sample3","sample4","sample5")
mydata <- t(mydata)
mydata <- as.data.frame(mydata)
b.plot <- ggplot(data=mydata, aes(x=row.names(mydata), y=sample1)) +
geom_bar(stat="identity" , color="green" , fill="yellowgreen", position="dodge" , width = 0.5) +
xlab("Genes") +
ylab("Expression") +
theme(axis.text.x = element_text(size = 10, angle = 45, hjust = 1),
plot.margin = margin(0.5,0.5,0.5,2, "cm"))
b.plot