title: How can I transform a dataframe with POSIXct dates into a time series?
body: <p>I have a data frame (DF) with two columns. In column one I have dates, in column two I have my value of interest (VOI).</p>
  
  <p>DF's display would be this: </p>
  
  <pre><code>|---------------------|------------------|
  |        Date         |        VOI       |
  |---------------------|------------------|
  |          Jan-1971   |         34       |
  |---------------------|------------------|
  |          Jan-1972   |         28       |
  |---------------------|------------------|
  |          Jan-1973   |         29       |
  |---------------------|------------------|
  |          Jan-1974   |         37       |
  |---------------------|------------------|
  |             ...     |         ...      |
  |---------------------|------------------|
  |          Jan-2017   |         36       |
  |---------------------|------------------|
  |          Fev-1971   |         48       |
  |---------------------|------------------|
  |          Fev-1972   |         49       |
  |---------------------|------------------|
  |          Fev-1973   |         52       |
  |---------------------|------------------|
  |          Fev-1974   |         50       |
  |---------------------|------------------|
  |          ...        |         ...      |
  |---------------------|------------------|
  |          Mar-1971   |         30       |
  |---------------------|------------------|
  |          ...        |         ...      |
  |---------------------|------------------|
  |          Mar-2017   |         36       |
  |---------------------|------------------|
  |          ...        |         ...      |
  |---------------------|------------------|
  |          Dez-1971   |         15       |
  |---------------------|------------------|
  |          ...        |        ...       |
  |---------------------|------------------|
  |          Dez-2017   |         19       |
  |---------------------|------------------|
  </code></pre>
  
  <p>In a nutshell, the data are presented in aggregated cycles of months. </p>
  
  <p>First I have all the VOIs for January from 1971 to 2017 (47 data points), then I have all the VOIs for February of the same period, hence, the same amount of points. This repetition goes on until December, also with 47 data points. </p>
  
  <p>I applied <strong>ymd()</strong> from the <strong>lubridate</strong> to transform my date into POSIXct values. </p>
  
  <p>Now I wanted to create a time series object out of my VOIs. I tried: </p>
  
  <pre><code>ts = xts(x = df$Vazao, order.by = index(df$Date))
  </code></pre>
  
  <p>and </p>
  
  <pre><code>ts = xts(x = df$Vazao, order.by = df$Data)
  </code></pre>
  
  <p>but none worked. I don't know where I am making a mistake, but I wonder it has anything to do with the fact my dates don't come chronologically. I thought that using the <strong>ymd()</strong> command would sort that out and "make R understand" that my times series goes from Jan 1971, Feb 1971, Mar 1971, ..., Dec 2017.</p>
  
  <blockquote>
    <p>How would I transform this data frame into a time series object?</p>
  </blockquote>
  
  <p>Thank you for your input.</p>