I have a dataset that looks like this:
the first column has all unique values, while the third column consists of 3 factors. I wanted to create a bar chart like so:
I've been trying to get it in ggplot and have done
ggplot(data, aes(as.factor(GO), pvalue, fill = Process)) +
geom_bar(position = "dodge", width = 0.5, stat = "identity")
but so far my plot looks like so:
what can I do to get the bars in order by the group?
Thanks in advance!
Here is a sample data:
GO <- c("T cell chemotaxis (GO:0010818)", "T cell chemotaxis (GO:0010818)",
"eosinophil chemotaxis (GO:0048245)", "CXCR3 chemokine receptor binding (GO:0048248)",
'hemokine activity (GO:0008009)', 'CXCR chemokine receptor binding (GO:0045236)',"cytoplasmic vesicle lumen (GO:0060205)",
"vesicle lumen (GO:0031983)", "collagen-containing extracellular matrix (GO:0062023)
")
pvalue <- c(2.49e-02, 3.07e-08, 1.90e-06, 2.22e-08, 1.72e-08, 1.63e-08, 6.18e-03, 3.87e-08
, 3.19e-07)
Process <- as.factor(rep(c("BP", "CP", "MP"),c(3,3,3)))
data <- data.frame(GO, pvalue,process)