EVOLUTION-MANAGER
Edit File: as.xts.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Convert Object To And From Class xts</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for as.xts {xts}"><tr><td>as.xts {xts}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2> Convert Object To And From Class xts </h2> <h3>Description</h3> <p>Conversion functions to coerce data objects of arbitrary classes to class <code>xts</code> and back, without losing any attributes of the original format. </p> <h3>Usage</h3> <pre> as.xts(x, ...) xtsible(x) Reclass(x) try.xts(x, ..., error = TRUE) reclass(x, match.to, error = FALSE, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p> data object to convert. See details for supported types </p> </td></tr> <tr valign="top"><td><code>match.to</code></td> <td> <p><code>xts</code> object whose attributes will be passed to <code>x</code></p> </td></tr> <tr valign="top"><td><code>error</code></td> <td> <p> error handling option. See Details. </p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p> additional parameters or attributes </p> </td></tr> </table> <h3>Details</h3> <p>A simple and reliable way to convert many different objects into a uniform format for use within <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span>. </p> <p>It is possible with a call to <code>as.xts</code> to convert objects of class <code>timeSeries</code>, <code>ts</code>, <code>irts</code>, <code>matrix</code>, <code>data.frame</code>, and <code>zoo</code>. </p> <p><code>xtsible</code> safely checks whether an object can be converted to an <code>xts</code> object; returning TRUE on success and FALSE otherwise. </p> <p>The help file <code>as.xts.methods</code> lists all available xts methods and arguments specific to each coercible type. </p> <p>Additional name=value pairs may be passed to the function to be added to the new object. A special print.xts method will assure that the attributes are hidden from view, but will be available via <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span>'s standard <code>attr</code> function, as well as the <code>xtsAttributes</code> function. </p> <p>The returned object will preserve all relevant attribute/slot data within itself, allowing for temporary conversion to use zoo and xts compatible methods. A call to <code>reclass</code> returns the object to its original class, with all original attributes intact - unless otherwise changed. </p> <p>It should be obvious, but any attributes added via the ... argument will not be carried back to the original data object, as there would be no available storage slot/attribute. </p> <p><code>Reclass</code> is designed for top-level use, where it is desirable to have the object returned from an arbitrary function in the same class as the object passed in. Most functions within <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> are not designed to return objects matching the original object's class. While this tool is highly experimental at present, it attempts to handle conversion and reconversion transparently. The caveats are that the original object must be coercible to <code>xts</code>, the returned object must be of the same row length as the original object, and that the object to reconvert to is the first argument to the function being wrapped. </p> <p><code>try.xts</code> and <code>reclass</code> are functions that enable external developers access to the reclassing tools within <span class="pkg">xts</span> to help speed development of time-aware functions, as well as provide a more robust and seemless end-user experience, regardless of the end-user's choice of data-classes. </p> <p>The <code>error</code> argument to try.xts accepts a logical value, indicating where an error should be thrown, a character string allowing for custom error messages to be displayed, or a function of the form <code>f(x, ...)</code>, to be called upon construction error. </p> <p>See the accompanying vignette for more details on the above usage and the package in general. </p> <h3>Value</h3> <p>An S3 object of class <code>xts</code>. </p> <p>In the case of <code>Reclass</code> and <code>reclass</code>, the object returned will be of the original class as identified by <code>CLASS</code>. </p> <h3>Author(s)</h3> <p> Jeffrey A. Ryan </p> <h3>See Also</h3> <p><code><a href="xts.html">xts</a></code>,<code><a href="as.xts.methods.html">as.xts.methods</a></code> </p> <hr /><div style="text-align: center;">[Package <em>xts</em> version 0.12.2 <a href="00Index.html">Index</a>]</div> </body></html>