Learn R Programming

xts (version 0.14.1)

as.environment.xts: 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. The name of each object in the resulting environment corresponds to the name of the column of the xts object.

Usage

# S3 method for xts
as.environment(x)

Value

An environment containing ncol(x) vectors extracted by column from x.

Arguments

x

An xts object.

Author

Jeffrey A. Ryan

Examples

Run this code

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)

Run the code above in your browser using DataLab