RParsingError:在 ipynb notebook 中运行 quantmod 库时出错

问题描述

我在 Google Colab 笔记本的 ipynb 中运行 R 代码。但是,代码RParsingError。但是,如果我用 0200.KL 替换 AAPL效果很好。

%load_ext rpy2.ipython

%%r
library(quantmod)
library(xts)
library(PerformanceAnalytics)
library(rugarch)

getSymbols(Symbols="0200.KL",src="yahoo",from="2020-1-1",to="2021-1-1")
0200.KL

但是,错误显示如下:

RParsingError:解析状态不正常 - PARSING_STATUS.PARSE_ERROR

有什么办法解决吗?

解决方法

解决了,下面是代码。

%%R
library(quantmod)
library(xts)
library(PerformanceAnalytics)
library(rugarch)

getSymbols(Symbols="0200.KL",src="yahoo",from="2016-1-1",to="2021-1-1") # function under quantmod library

REV = `0200.KL`
# remove the original dataframe from your workspace
rm(`0200.KL`)

#change column names
colnames(REV) = c("Open","High","Low","Close","Volume","Adjusted Close")

chartSeries(REV["2020-12"]) # under quantmod,plot dec 2020 ohlc data
chartSeries(REV$Close,theme="white")