I'm trying to understand how to have more than one series on a plot, using the following data.
Year <- c('1950', '1960', '1970', '1980')
Bus <- c(10,20,30,40)
Bus.sd <- c(1.1, 2.2, 3.3, 4.4)
Car <- c(20, 20, 40, 40)
Car.sd <- c(1.1, 2.2, 3.3, 4.4)
sample_data = data.frame(Year, Bus, Bus.sd, Car, Car.sd)
qplot(Year, Bus, data=sample_data, geom="pointrange",
ymin = Bus - Bus.sd/2, ymax = Bus + Bus.sd/2)
For example, using the above data, how do I show both sample_data$Bus and sample_data$Car on the same plot in different colors?
What I tried doing was:
p <- qplot(...)
then
p <- p + qplot(...)
where I replicated the previous line, but this gave me an error.
I don't fully understand how AES works. I have studied the ggplot2 examples, but have difficulty understanding the relevant examples here. Or, if it is possible to make a stacked bar (geom_bar) using this data, I think that would also represent it appropriately.