chart.Scatter() in PortfolioAnalytics package corrupted

别说谁变了你拦得住时间么 提交于 2019-12-23 06:06:06

问题


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:

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.


回答1:


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 :-)



来源:https://stackoverflow.com/questions/49522143/chart-scatter-in-portfolioanalytics-package-corrupted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!