title: How can I read a date series of quarterly data into R?
body: <p>I have a dataset, the first column of which is the date in the format Year-Quarter, like the following</p>
  
  <pre><code> 1959-I   
   1959-II   
   1959-III   
   1959-IV    
   1960-I   
   1960-II   
   1960-III   
   1960-IV   
  </code></pre>
  
  <p>I have imported the dataset into R, but I don't know how to convert this to <code>Date</code> format using the <code>as.Date</code> function, since <a href="http://stat.ethz.ch/R-manual/R-patched/library/base/html/strptime.html" rel="noreferrer">there doesn't appear to be a conversion specification for quarters</a> and I have just started learning R.</p>
  
  <p>The best I can think of is something like</p>
  
  <pre><code>#extract the year
  &gt; dates &lt;- substring(data$X,1,4)
  &gt; dates[1:8]
  [1] "1959" "1959" "1959" "1959" "1960" "1960" "1960" "1960"
  &gt; dates &lt;- as.numeric(dates)
  
  #extract the quarter
  &gt; quarters &lt;- substring(data$X,6)
  &gt; quarters[1:10]
  [1] "I "   "II "  "III " "IV "  "I "   "II "  "III " "IV "
  </code></pre>
  
  <p>but this cannot possibly be the best way of doing this, and it still leaves me the problem of how to deal with my series <code>quarters</code>. To make matters worse, there is a blank character at the end of each character I don't know how to deal with because there are 3 different "lenghts" for the quarters strings.</p>
  
  <p>Another option, of course, would be to fabricate my own quarters series, with something like</p>
  
  <pre><code>quarters &lt;- rep(c(1,2,3,4),dates[length(dates)]-dates[1])
  </code></pre>
  
  <p>(I am quite proud of myself for having written this last line!).</p>
  
  <p><strong>So my question:</strong> is there a built-in way to import quarterly data in the format I have in R, and if not, any other format (still for quarterly data)? Any suggestions on the best way to proceed?</p>