title: Format Date to Year-Month in R
body: <p>I would like to retain my current date column in year-month format as date. It currently gets converted to chr format. I have tried as_datetime but it coerces all values to NA. 
  The format I am looking for is: "2017-01"</p>
  
  <pre><code>library(lubridate)
  df&lt;- data.frame(Date=c("2017-01-01","2017-01-02","2017-01-03","2017-01-04",
                         "2018-01-01","2018-01-02","2018-02-01","2018-03-02"),
              N=c(24,10,13,12,10,10,33,45))
  df$Date &lt;- as_datetime(df$Date)
  df$Date &lt;- ymd(df$Date)
  df$Date &lt;- strftime(df$Date,format="%Y-%m")
  </code></pre>
  
  <p>Thanks in advance!</p>