xtsdf: Create Or Test For An xtsdf Time-Series Object

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Constructor function for creating an extensible time-series data.frame object.

xtsdf is used to create an xtsdf object from raw data inputs and as.xtsdf is used for coercion to the same.

Usage

1
2
3
4
5
xtsdf(..., order.by = index(x), frequency = NULL, unique = TRUE, tzone = Sys.getenv("TZ"), stringsAsFactors = default.stringsAsFactors(), check.names = TRUE)

as.xtsdf(x, ...)

is.xtsdf(x)

Arguments

...

Columns of the resulting xtsdf object. Names will be extracted as with data.frame

order.by

a corresponding vector of unique times/dates - must be of a known time-based class. See details of xts.

frequency

numeric indicating frequency of order.by. See details of xts.

unique

Logical. Should index be checked for unique time-stamps?

tzone

time zone of series

stringsAsFactors

Logical. Should strings be converted to factors? Note that xts does not currently support factors so this doesn't really do much..

check.names

Logical. Should column names be made syntactically correct?

x

An object to be tested or coerced to class xtsdf.

Details

An xtsdf object creates a time ordered data.frame like object; internally it is implemented as a list of xts objects, but it should behave like a data.frame rather transparently. The class is still under heavy development and feedback is welcome. Imporantly, this now allows xts-like behavior for objects with different column classes.

Subsetting inherits ISO8601 subsetting from xts as well as standard R subsetting. Double bracket ([[) subsetting inherits from the underlying list structure. Note that the default for subsetting is drop = FALSE following xts rather than data.frame. This is subject to change.

Value

An S3 object of class xtsdf.

Author(s)

Michael Weylandt

See Also

help("xts")

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
data(sample_matrix)
sample.xtsdf <- xtsdf(fac = letters[sample(26, 100, replace = TRUE)], x = rnorm(100), y = abs(rnorm(100)), order.by = as.Date("2012-06-19") + 1:100)

class(sample.xtsdf)
str(sample.xtsdf)

head(sample.xtsdf)  

sample.xtsdf['2012']  # all of 2012
sample.xtsdf['2007-07/']  # July 2012 to the end of the data set
sample.xtsdf['2007-07/2007-08']  # March 2007 to August of 2007
sample.xtsdf['/'] # the whole data set

sample.xtsdf[["x"]]

sample.xtsdf[,"fac"]

R-Finance/xtsExtra documentation built on May 8, 2019, 4:51 a.m.