xtsToDataFrame: Convert and xts object to a data frame, suitable for use in...

Description Usage Arguments Value Examples

View source: R/xtsToDataFrame.R

Description

A function to convert an xts object into a data frame that can be plotted usinfg ggplot2. The date column will be the first column of the new data frame and will have the name 'Date'. This function uses a recursive implementation for xts objects with many columns.

Usage

1
xtsToDataFrame(xts.obj)

Arguments

xts.obj

an xts object.

Value

a dataframe suitable for plotting in ggplot2. Date will be first column.

Examples

1
2
3
4
5
dts <- seq(Sys.Date()-4, Sys.Date(), 1)
returns <- matrix(rnorm(10),ncol = 2) / 100
ret.xts <- xts(returns, dts)
names(ret.xts) <- c("Asset_1","Asset_2")
xtsToDataFrame(ret.xts)

gtog/dMisc documentation built on May 17, 2019, 8:57 a.m.