Search code examples
rquantmodr-portfolioanalytics

chart.Scatter() in PortfolioAnalytics package corrupted


Running the short R-code below in R Studio (v1.0.143, Win7, R-3.4.4, Performance Analytics 1.5.2, quantmod 0.4-12) returns the following chart:

enter image description here

library(PortfolioAnalytics)
library(quantmod)

getSymbols("INDU", src = "yahoo", from = "2017-01-01", to = "2017-06-26")
getSymbols("VZ", src = "yahoo", from = "2017-01-01", to = "2017-06-26")

ret_INDU <- Return.calculate(Cl(INDU))[-1,]
ret_VZ <- Return.calculate(Cl(VZ))[-1,]

chart.Scatter(ret_INDU, ret_VZ)

It looks like something went seriously wrong with it. Could someone have a look if this is reproducible? I already upgraded to the latest version of R.


Solution

  • You have to set xlab = “” and ylab = “”. It seems that the default valueNULL is the problem. If you explicitly select the columns you will avoid problems with objects with more than 1 columns. The line:

    chart.Scatter(ret_INDU$INDU.Close, ret_VZ$VZ.Close,xlab = "",ylab=“")
    

    should give you your chart in all its glory :-)