PortfolioAnalytics 包中的 chart.Scatter() 已损坏 [英] chart.Scatter() in PortfolioAnalytics package corrupted

查看:48
本文介绍了PortfolioAnalytics 包中的 chart.Scatter() 已损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 R Studio(v1.0.143、Win7、R-3.4.4、Performance Analytics 1.5.2、quantmod 0.4-12)中运行下面的简短 R 代码返回以下图表:

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)

它好像出了点问题.有人可以看看这是否可重现吗?我已经升级到最新版本的 R.

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.

推荐答案

你必须设置 xlab = "ylab = ".似乎默认值NULL 是问题所在.如果您明确选择列,您将避免超过 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 :-)

这篇关于PortfolioAnalytics 包中的 chart.Scatter() 已损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆