Skip to content

Commit 78a24c3

Browse files
committed
Add documentation for .xts() constructor
1 parent a184c79 commit 78a24c3

File tree

1 file changed

+35
-12
lines changed

1 file changed

+35
-12
lines changed

man/xts.Rd

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
\name{xts}
22
\alias{xts}
3+
\alias{.xts}
34
\alias{is.xts}
45
\title{ Create Or Test For An xts Time-Series Object }
56
\description{
@@ -15,22 +16,44 @@ xts(x = NULL,
1516
tzone = Sys.getenv("TZ"),
1617
...)
1718

19+
.xts(x = NULL,
20+
index,
21+
tclass = c("POSIXct", "POSIXt"),
22+
tzone = Sys.getenv("TZ"),
23+
check = TRUE,
24+
unique = FALSE,
25+
...)
26+
1827
is.xts(x)
1928
}
2029

2130
\arguments{
2231
\item{x}{ an object containing the time series data }
23-
\item{order.by}{ a corresponding vector of unique times/dates - must be
24-
of a known time-based class. See details. }
25-
\item{frequency}{ numeric indicating frequency of \code{order.by}. See details. }
26-
\item{unique}{ should index be checked for unique time-stamps? }
27-
\item{tzone}{ time zone of series. This is ignored for Date indices }
28-
\item{\dots}{ additional attributes to be added. See details. }
32+
\item{order.by}{ a corresponding vector of dates/times of a known time-based
33+
class. See Details. }
34+
\item{index}{ a corresponding \emph{numeric} vector specified as seconds
35+
since the UNIX epoch (1970-01-01 00:00:00.000) }
36+
\item{frequency}{ numeric indicating frequency of \code{order.by}. See Details. }
37+
\item{unique}{ check the index for unique timestamps? }
38+
\item{check}{ check that the index is ordered? }
39+
\item{tclass}{ time class to use for the index. See code{\link{tclass}}. }
40+
\item{tzone}{ time zone of the index (ignored indices without a time
41+
component, e.g. Date, yearmon, yearqtr). See \code{\link{tzone}}. }
42+
\item{\dots}{ additional attributes to be added. See Details. }
2943
}
3044
\details{
3145
An \code{xts} object extends the S3 class \code{zoo} from the package of the
3246
same name.
3347

48+
The \code{xts()} constructor is the preferred way to create xts objects. It
49+
performs several checks to ensure it returns a well-formed xts object. The
50+
\code{.xts()} constructor is mainly for internal use. It is more efficient than
51+
the regular \code{xts()} constructor because it doesn't perform as many
52+
validity checks. Use it with caution.
53+
54+
% TODO: add notes here about the differences between 'empty', 'zero-width', and
55+
% 'zero-length' xts objects.
56+
3457
Similar to zoo objects, xts objects must have an ordered index. While zoo
3558
indexes cannot contain duplicate values, xts objects have optionally supported
3659
duplicate index elements since version 0.5-0. The \code{xts} class has one
@@ -51,7 +74,7 @@ incorrect format, non-existent time due to daylight saving time, etc). Because
5174
of how non-finite numbers are represented, a missing timestamp will always be
5275
at the end of the index (except if it is \code{-Inf}, which will be first).
5376
54-
Another difference is that the object may now carry additional
77+
Another difference from \pkg{zoo} is that xts object may carry additional
5578
attributes that may be desired in individual time-series handling.
5679
This includes the ability to augment the objects data with
5780
meta-data otherwise not cleanly attachable to a standard zoo object.
@@ -68,7 +91,7 @@ the object in a manner required by the user.
6891
Many xts-specific methods have been written to better handle the
6992
unique aspects of xts. These include, \sQuote{"["}, merge, cbind,
7093
rbind, c, Ops, lag, diff, coredata, head and tail. Additionally
71-
there are xts specific methods for converting amongst R's different
94+
there are xts specific methods for converting to/from R's different
7295
time-series classes.
7396
7497
Subsetting via "[" methods offers the ability to specify dates by
@@ -86,8 +109,8 @@ Leading zeros are not necessary. See the examples for more detail.
86109
Users may also extend the \code{xts} class to new classes to
87110
allow for method overloading.
88111
89-
Additional benefits derive from the use of \code{as.xts} and
90-
\code{reclass}, which allow for lossless two-way conversion
112+
Additional benefits derive from the use of \code{\link{as.xts}} and
113+
\code{\link{reclass}}, which allow for lossless two-way conversion
91114
between common R time-series classes and the \code{xts} object
92115
structure. See those functions for more detail.
93116
@@ -108,8 +131,8 @@ automagically handle \emph{all} data objects
108131
as one would handle a \code{zoo} object.
109132
110133
}
111-
\seealso{ \code{\link{as.xts}}, \code{\link{reclass}},
112-
\code{\link{xtsAttributes}} }
134+
\seealso{ \code{\link{as.xts}}, \code{\link{index}}, \code{\link{tclass}},
135+
\code{\link{tformat}}, \code{\link{tzone}}, \code{\link{xtsAttributes}} }
113136
\examples{
114137
data(sample_matrix)
115138
sample.xts <- as.xts(sample_matrix, descr='my new xts object')

0 commit comments

Comments
 (0)