r: convert a string to date : <p>I have a string like that:</p>

<pre><code>201601 
201603 
201604 
201606 
201501
</code></pre>

<p>And I'd like to convert to Date, like so:</p>

<pre><code>2016-01
2016-03
2016-04
2016-06
2015-01
</code></pre>

<p>I have tried:<code>df$month_key=as.Date(df$month_key,format="YYYYmm")</code>
But it asks for the origin, which we don't need to care about.
Is there a way to do that, or maybe add a dash between character 4 and 5 in the whole column?
Thanks</p>
