I have a data frame "test" that looks like this. There are no N/A or inf. All days are populated with data.
head(test)
businessdate strategy 1 Strategy 2
1 2014-01-01 0.000000000 0.0000000
2 2014-01-02 0.010058520 -0.3565398
3 2014-01-03 0.000707818 0.2622737
4 2014-01-06 -0.019879142 -0.2891257
5 2014-01-07 -0.019929352 -0.2271491
6 2014-01-08 0.027108810 -0.7827856
When I look at the class of the those columns I see:
> class(test[,1])
[1] "POSIXct" "POSIXt"
> class(test[,2])
[1] "numeric"
> class(test[,3])
[1] "numeric"
So I think I can turn this into an xts object and to use Performance analytics. Here I turn it into a xts:
test_xts<- xts(test, order.by= test[,1])
Now I try to use the Performance analytics package and get an error:
charts.PerformanceSummary(test_xts,geometric= TRUE,cex.axis=1.5)
The error I get is:
Error in na.omit.xts(x) : unsupported type
Any idea what is happening and how to fix it?
xts/zoo objects are a matrix with an index attribute. You can't mix types in a matrix. There's no need to specify the businessdate
as the index and in the coredata, so do not include it in the coredata.
test_xts <- xts(test[,-1], order.by= test[,1])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With