Re: [问题] quantmod 绘制股价交易时序图

楼主: andrew43 (讨厌有好心推文后删文者)   2015-04-14 05:32:58
library(quantmod)
txt <- "Date Open High Low Close Volume
2013/1/2 13257 13289 13162 13194 168353
2013/1/3 13195 13198 13055 13055 242457
2013/1/4 13050 13100 13005 13079 256215
2013/1/7 13085 13128 13025 13126 228488
"
dat <- read.table(textConnection(txt), header=T, sep=" ", row.names="Date")
## 关键是 barChart() 要喂食一个 xts 物件
## 参考 ?xts 及 ?sample_matrix
## 以下是想办法生成 xts 物件的过程
dat.xts <- as.xts(as.matrix(dat))
## 画画看吧。结果对或错都请推个文告诉我一声。
barChart(dat.xts)
※ 引述《psinqoo (零度空间)》之铭言:
:
: 问题 图跑不出
:
: [问题类型]:
:
: 程式咨询
:
: [软件熟悉度]:
:
: 入门
:
: [问题叙述]:
:
: 是不是资料格式错误? 还是其他方面有问题?
: barChart 画不出来 其他的也无法画出
: 底下是资料格式
: 读入 .csv
: 资料格式 如下
: Date Open High Low Close Volume
: 2013/1/2 13257 13289 13162 13194 168353
: 2013/1/3 13195 13198 13055 13055 242457
: 2013/1/4 13050 13100 13005 13079 256215
: 2013/1/7 13085 13128 13025 13126 228488
:
: [程式范例]:
:
: euo=read.csv(file.choose())
: head(euo)
: library(quantmod)
: barChart(euo)
: 出现
: Error in try.xts(x, error = "chartSeries requires an xtsible object") :
: chartSeries requires an xtsible object
:
: quantmod
: xts
:
:

Links booklink

Contact Us: admin [ a t ] ucptt.com