Search code examples
rperformanceanalytics

chart.CumReturns legend.loc="right" giving "Error in legend"


I'm trying to do a cumulative returns chart, which is working great till I try and add a legend. Here is the line that works fine:

chart.CumReturns(All.dat[,1], wealth.index = FALSE, geometric = TRUE)

and here is the line that gives an error:

chart.CumReturns(All.dat[,1], wealth.index = FALSE, geometric = TRUE, legend.loc = "right")

Here is the error:

ERROR while rich displaying an object: Error in legend(x = lc$x, y = lc$y, legend = legend.names, xjust = lc$xjust, : 'legend' is of length 0

Any ideas what I'm doing wrong?


Solution

  • The problem was that I didn't have a column name. As soon as I named my column this worked fine.