index.xts incompatible with PerformanceAnalytics charts.PerformanceSummary
Closed this issue · 2 comments
Following up on this issue...
#2
Here's an example to reproduce the problem:
library(PerformanceAnalytics)
example(charts.PerformanceSummary)
works
setInternet2(TRUE)
con = gzcon(url('https://github.com/systematicinvestor/SIT/raw/master/sit.gz', 'rb'))
source(con)
close(con)
example(charts.PerformanceSummary)
generates an error: Error in xts(rep(NA, length(time(x))), order.by = time(x)) :
order.by requires an appropriate time-based object
rm(index.xts)
example(charts.PerformanceSummary)
works again.
The code crash is inside the function
chart.BarVaR, at line 47.
chart.BarVaR is called by charts.PerformanceSummary.
The 'x' parameter in the function is the data 'edhec',
so I can substitute it.
At approx line 34 of chart.BarVaR, is this conversion:
time(x) = as.Date(time(x))
Compare results:
without SystematicInvestor,
class(time(edhec))
[1] "Date"
and
xts(rep(NA,length(time(edhec))), order.by = time(edhec))
works okay.
But with SystematicInvestor, as.Date() has a different
class:
class(time(edhec))
[1] "POSIXct"xts(rep(NA,length(time(edhec))), order.by = time(edhec))
Error in xts(rep(NA, length(time(x))), order.by = time(x)) :
order.by requires an appropriate time-based object
fixed