Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

as.environment

Coerce an ‘xts’ Object to an Environment by Column


Description

Method to automatically convert an ‘xts’ object to an environment containing vectors representing each column of the original xts object. Each objects will be named according to the column name it is exracted by.

Usage

## S3 method for class 'xts'
as.environment(x)

Arguments

x

an xts object

Details

An experimental tool to convert xts objects into environments for simplifying use withing the standard R formula/data paradigm.

Value

An environment containing ncol(x) vectors extracted by column from x. Note that environments do not preserve (or have knowledge) of column position, a.k.a order.

Author(s)

Jeffrey A. Ryan

Examples

x <- xts(1:10, Sys.Date()+1:10)
colnames(x) <- "X"
y <- xts(1:10, Sys.Date()+1:10)
colnames(x) <- "Y"
xy <- cbind(x,y)
colnames(xy)
e <- as.environment(xy)    # currently using xts-style positive k 
ls(xy)
ls.str(xy)

xts

eXtensible Time Series

v0.12.1
GPL (>= 2)
Authors
Jeffrey A. Ryan [aut, cph], Joshua M. Ulrich [cre, aut], Ross Bennett [ctb], Corwin Joy [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.