Re: [R] ggplot2 / time series with different scales

2010-02-05 Thread Chuck White
Thank you both for your response. As the names suggest, I am plotting the sales & price data for items over time to understand the how certain items may be more responsive than others to price changes. Another way of displaying this information on the same chart as the one showing sales, would

Re: [R] ggplot2 / time series with different scales

2010-02-04 Thread Xie Chao
you can use facet_wrap: df <- melt(df, id=c('time', 'sid')) ggplot(df, aes(time, value, colour=sid)) + geom_line(data = subset(df, variable=='sales')) + geom_point(data = subset(df, variable=='price')) + facet_wrap(~variable, ncol=1, scales='free_y') Xie Chao On Fri, Feb 5, 2010 at 12:2

Re: [R] ggplot2 / time series with different scales

2010-02-04 Thread Dieter Menne
chuckwhite wrote: > > I am trying to plot this dataset using ggplot2: > > .. self-contained example removed > > How can I plot the price (using geom_point) in a separate plot just above > the sales plot so that the xaxes match and the yaxes are different. > > To quote Hadley Wickham: http:/

[R] ggplot2 / time series with different scales

2010-02-04 Thread Chuck White
I am trying to plot this dataset using ggplot2: df <- data.frame( sid = c(rep('11',30),rep('22',30)), time = rep(ISOdate(year = 2010, month = 1, day = 1:30),2), sales = c(rnorm(30, 1000, 20),rnorm(30, 900, 10)), price = c(rnorm(30, 2, 0.5),rnorm(30, 3,0.5)) ) Plotting just the sales