title: faceting monthly data by year in r - months with no data appear
body: <p>I'm trying to create a grouped bar chart of monthly data, aggregated from daily data, over multiple years. I have accomplished what I wanted from my x-axis from faceting, using faceting as a way to apply a secondary sort (on year and month). Now that I've faceted by year, ggplot is showing all months - even when there's no data. This is wasting space and my actual data set has years of data and I want to add labels, so space is an issue. </p>
  
  <p>How can I accomplish this without the wasted space? Is there a way to add the secondary sort (year,month) on the x-axis without faceting? </p>
  
  <p><img src="https://i.stack.imgur.com/9uBxw.png" alt="ggplot example"> </p>
  
  <pre><code># create data set
  date = seq(as.Date("2014-05-01"),as.Date("2015-05-10"), "day")
  revenue = runif(375, min = 0, max = 200)
  cost = runif(375, min = 0, max = 100)
  df = data.frame(date,revenue,cost)
  head(df)
  
  # adding month and year column, then aggregating to monthly revenue and cost 
  library(plyr)
  df$month &lt;- month(df$date, label=TRUE) 
  df$year &lt;- year(df$date) 
  df &lt;- as.data.frame(ddply(df, .(month,year), numcolwise(sum)))
  
  # melting the data for a 'grouped chart' in ggplot
  library(reshape)
  df &lt;-melt(df, id = c("month","year"))
  
  #create chart
  library(ggplot2)
  g &lt;-ggplot(df, aes(x=month, y=value, fill=variable)) 
  g + geom_bar(stat="identity", position="dodge") + facet_wrap(~ year)
  </code></pre>
  
  <p>I feel certain that there's a more elegant way to do this from within ggplot. Am I right?</p>