I have a data frame with two columns, A and B. I want to produce a bar plot with values in A and B plotted side by side (dodged). I googled around and found ggplot from package ggplot2. The default is to generate a bar chart using frequencies, but there is an option stat="identity" that allows to pick a variable to set bar heights explicitly. I can plot one column like so:
d <- data.frame(A=c(1:10), B=c(11:20))
ggplot(data=d, aes(x=1:length(A), y=A))+geom_bar(stat="identity", position="dodge")
How do I plot two columns side by side? I can structure my data frame differently: append values from vectors A and B into one column and create an indicator variable ind, then use it to define groups aes(group=ind). Can this be done with data frame d as-is, without modifying its structure?