title: plotting monthly and yearwise weather data in r
body: <p>I am trying to develop a weather plot like that appears in weather data - something like. </p>
  
  <p><img src="https://i.stack.imgur.com/q6WzJ.jpg" alt="enter image description here"></p>
  
  <p>I want to plot daily value (although average value can appear in circle).  I am using ggplot2 as it need multifaceted (for each month and year). </p>
  
  <pre><code>st &lt;- as.Date ("2009-1-1")
  en &lt;- as.Date ("2011-12-28")
  date1 &lt;- seq(st, en, "1 day")
  year &lt;- format(date1, "%Y")
  month &lt;- format (date1, "%b")
  day &lt;- as.numeric (format(date1, "%d"))
  
  avgtm &lt;- round (rnorm (length(date1), 50,5), 1)
  maxtm &lt;- avgtm + abs(rnorm (length (avgtm), 0, 5))
  mintm &lt;-  avgtm - abs(rnorm (length (avgtm), 0, 5))
  
  myd &lt;- data.frame ( year, month, day, avgtm, maxtm, mintm)
  require(ggplot2)
  qplot(day, avgtm, data = myd, geom = "line", col = "red") +
  facet_grid(year ~ month) + theme_bw()
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/idVXs.jpg" alt="enter image description here"></p>
  
  <p>There is one major problem here, line will connect between months. </p>
  
  <p>Each month is plotted to maximum (although one month can end in 28, leaving blank at the month).
  <img src="https://i.stack.imgur.com/fd4Am.jpg" alt="enter image description here"></p>
  
  <p>Is there a smart way to achieve what I want to achieve. I tried ggplot2 but there might be other nice options. </p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I am trying to add vertical line at the first day of month to demark the months. Here is I tried to find the first day of month:</p>
  
  <pre><code> td = as.Date (seq(as.Date("2009/1/1"), as.Date("2011/12/28"), "months"))
  </code></pre>
  
  <p>I tried to use this to plot line:</p>
  
  <pre><code>qplot(date, avgtm, data = myd, geom = "line", col = "red") +
    facet_wrap(~year, scales='free_x', ncol=1, nrow=3) +
  
     geom_vline(xintercept=td, linetype="dotted") + theme_bw()
  </code></pre>
  
  <p>But running an error:
  Error : Invalid intercept type: should be a numeric vector, a function, or a name of a function</p>
  
  <p>How can plot the vertical line with the date ? </p>