makeXTS: Convert a dataframe of returns to xts format.

Description Usage Arguments Value Examples

View source: R/makeXTS.R

Description

Supposing you have read in a data file that has the first column containing dates followed by subsequent columns of asset returns, this function will convert that dataframe into an xts object suitable for analysis with xts based analysis routines, like PerformanceAnalytics.

Usage

1
makeXTS(x, format = "%Y-%m-%d", names = colnames(x)[2:ncol(x)])

Arguments

x

a data frame of returns with the first column a date column labeled 'Date'.

format

a recognized date format. Defaults to "Y-m-d" format.

names

a vector of names for each of the columns, excluding the date column. Defaults to the colnames of the dataframe x[2:ncol(x)].

Value

an xts object based on x.

Examples

1
2
mydata <- read.csv("mydata.csv",sep = ",")
mydata.xts <- makeXTS(mydata)

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