我在 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
有什么办法解决吗?
答案 0 :(得分:0)
解决了,下面是代码。
%%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")