I\'m trying to make a stacked bar plot with the following dataframe:
totalleft
1S 2S 3S 4S 12S 25S tests
A-000 5 0 10 10 0 NA A-000
A-0
This seems like what you wanted??
library(reshape2)
library(ggplot2)
gg <- melt(totalleft,id="tests")
ggplot(gg) +
geom_bar(aes(x=tests, y=value, fill=variable), stat="identity")+
theme(axis.text.x=element_text(angle=-90, vjust=.2, hjust=0))
melt(...)
converts your data frame from "wide" format (groups in different columns) to "long" format (all the values in one column (called value
), and groups distinguished by a separate column (called variable
).