I have different quarters like
Quarter GrossMargin
2009 Q1 17.60%
2009 Q1 17.80%
2010 Q2 18.50%
2011 Q1 21.60%
See like this i have big data set. I want to plot this in R. I used qplot(df$Quarter, df$GrossMargin, binwidth=.5)
It came dots at the data points of each occurance. Like in x-axis 2009 Q1 there are correspondingly two data points in Y-axis one at 17.6 and other at 17.8. But i want an average value for each quarter, like in x-axis 2009 Q1 should correspond to the single value in Y-axis (that is average of 17.6 and 17.8). If i try to do mean(GrossMargin), it gives mean of whole column, which is of no use. All my quarters(2009-Q1,Q2,Q3, 2010-Q1,Q2,Q3) are in one column and corresponding values of GrossMargin in other single column. How to do this in R
Quarter GrossMargin
2009 Q1 17.60%
2009 Q1 17.80%
2009 Q1 22.40%
2009 Q1 17.70%
2009 Q1 17.50%
2009 Q1 17.50%
2009 Q1 18.40%
2009 Q1 18.70%
2009 Q1 21.10%
2009 Q1 13.60%
2009 Q1 17.70%
2009 Q1 17.70%
2009 Q1 18.50%
2009 Q1 17.70%
2009 Q1 18.20%
2009 Q1 30.20%
2009 Q1 17.60%
2009 Q1 19.00%
2009 Q1 14.60%
2009 Q1 17.50%
2009 Q1 18.40%
2009 Q1 21.60%
2009 Q1 21.10%
2009 Q1 18.40%
2009 Q1 17.30%
2009 Q1 14.60%
2009 Q1 17.60%
2009 Q1 17.50%
2009 Q2 17.50%
2009 Q1 14.60%
2009 Q1 17.60%
2009 Q1 17.70%
2009 Q1 17.70%
2009 Q1 17.30%
2009 Q1 17.60%
2009 Q1 18.50%
2009 Q1 18.20%
2009 Q1 17.50%
2009 Q1 17.70%
2009 Q1 17.70%
2009 Q1 17.70%
2009 Q1 30.20%
2009 Q1 17.60%
2009 Q1 18.40%
2009 Q1 30.20%
2009 Q1 18.50%
2009 Q1 39.30%
2009 Q1 17.50%
2009 Q1 17.70%
2009 Q1 17.70%
2009 Q1 17.30%
2009 Q1 19.40%
2009 Q1 20.90%
2009 Q1 17.70%
2009 Q1 18.70%
2009 Q1 17.50%
2009 Q1 17.70%
2009 Q1 17.50%
2009 Q1 17.50%
2011 Q1 18.20%
2011 Q1 17.60%
2011 Q1 17.70%
2011 Q1 17.70%
2011 Q1 18.50%
2011 Q1 19.00%
2011 Q1 21.60%
2011 Q1 17.50%
2011 Q1 14.60%
2011 Q1 30.20%
2011 Q1 18.40%
2009 Q1 21.10%
2010 Q2 17.50%
2010 Q2 17.70%
2010 Q2 17.70%
2010 Q2 17.50%
2010 Q2 17.50%
2010 Q2 18.20%
2010 Q2 18.50%
2010 Q2 17.70%
2010 Q2 17.60%
2010 Q2 17.30%
2010 Q2 14.60%
2010 Q2 17.70%
2010 Q2 18.40%
2010 Q2 17.60%
2009 Q1 17.70%
2009 Q1 19.40%
2009 Q1 17.50%
2009 Q1 17.50%
2009 Q1 20.90%
2009 Q1 19.00%
2009 Q1 17.60%
2009 Q1 17.70%
2009 Q1 19.00%
2009 Q1 17.70%
2009 Q1 17.50%
2009 Q1 17.50%
2009 Q1 17.50%
the are other 5 columns which are Order.id customer id, date etc