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