title: How to transform an R Matrix into an xts/zoo object?
body: <p>aI'm having a problem transforming an xts derived R Matrix back into an xts object after running the returns function. Here's what I've got...</p>
  
  <pre><code>&gt;    class(xtsData)
  [1] "xts" "zoo"
  
  &gt; head(xtsData)
             ts_58_20_B_003_003 ts_58_20_S_021_005 ts_58_20_S_034_013 ts_58_20_S_042_021
  2011-01-02            10001.0            10000.0              10000              10000
  2011-01-03            10387.5            10001.0              10000              10000
  2011-01-04            10387.5            10551.0              10000              10000
  2011-01-05            10387.5            10562.5              10000              10000
  2011-01-06            10387.5            10562.5              10000              10000
  2011-01-07            10387.5            10562.5              10000              10000
  &gt; tail(xtsData)
             ts_58_20_B_003_003 ts_58_20_S_021_005 ts_58_20_S_034_013 ts_58_20_S_042_021
  2013-03-05            21199.0              14905            10274.5               8859
  2013-03-06            20498.0              14905            10274.5               8859
  2013-03-07            20484.5              14905            10274.5               8859
  2013-03-08            20957.5              15478            10847.5               9432
  2013-03-11            20957.5              15478            10847.5               9432
  2013-03-12            20531.5              14776            10847.5               9432
  </code></pre>
  
  <p>Following a procedure in the RMetrics documentation...</p>
  
  <pre><code>&gt; xtsDataDiff &lt;- xtsData[, ] / as.numeric( xtsData[1, ] )
  &gt; class( xtsDataDiff )
  [1] "xts" "zoo"
  </code></pre>
  
  <p>When I apply the returns function I lose the returned object as an xts object...</p>
  
  <pre><code>&gt; xtsData_1 &lt;- returns( xtsDataDiff )
  &gt; class(xtsData_1)
  [1] "matrix"
  &gt; tail ( xtsData_1 )
             ts_58_20_B_003_003 ts_58_20_S_021_005 ts_58_20_S_034_013 ts_58_20_S_042_021
  2013-03-05       0.0000000000       -0.000099995        0.000099995        0.000000000
  2013-03-06      -0.0337266853        0.000099995        0.000000000        0.000000000
  2013-03-07      -0.0005588228        0.000000000        0.000000000       -0.000099995
  2013-03-08       0.0228280749        0.037722934        0.054169546        0.062774267
  2013-03-11       0.0000000000       -0.000099995        0.000099995        0.000000000
  2013-03-12      -0.0206362804       -0.046315423        0.000000000        0.000000000
  </code></pre>
  
  <p>When I try to re-establish the data set as an xts object I get an error.</p>
  
  <p>So my question is this... How do I re-establish the data of the matrix as an xts object?</p>