title: Extract Month and Year From Date in R
body: <p>I have tried a number of methods to no avail. I have data in terms of a date (YYYY-MM-DD) and am trying to get in terms of just the month and year, such as: MM-YYYY or YYYY-MM.</p>
  
  <p>Ultimately, I would like it to look like this:</p>
  
  <pre><code>ID    Date         Month_Yr
  1     2004-02-06   2004-02
  2     2006-03-14   2006-03
  3     2007-07-16   2007-07
  ...   ...          ...
  </code></pre>
  
  <p>I am doing this in hopes of plotting money earned on average in a month, from a number of orders, over a period of time. Any help, or a push in the right direction would be much appreciated. </p>