[英]Time Series - plot.ts() and multiple graphs
我已經看到幾個關於錯誤的線程
cannot plot more than 10 series as "multiple"
但是沒有人真正解釋(1)發生了什么,以及(2)如果有多個圖形,該如何解決。
我有12個不同的文件。 每個文件都是1行,大約240-250個數據點。 這是時間序列數據。 值范圍在文件之間變化。
我想制作一張圖,將它們全部放在一個圖上。 所以像par(mfrow =(4,3))這樣的東西。
但是,當我使用我的代碼時,它給了我上面的錯誤。
for(cand in cands)
{
par(mfrow=c(4,3))
for(type in types)
{
## Construct the file name
curFile = paste(folder, cand, base, type, close, sep="")
## Read in the file
ts = read.delim(curFile, sep="\t", stringsAsFactors=FALSE, header=FALSE, row.names=NULL,fill=TRUE, quote="", comment.char="")
plot.ts(ts)
}
}
首先,不要將時間序列對象稱為“ ts”。 這就像稱呼您的狗為“狗”。 系統中使用了“ ts”,這可能導致混亂。
通過讀取文件來查看“ ts”的結構。 根據您的描述,該文件是否是包含240多個列的單行? 如果是這樣,那也將是一個問題。
read.delim()
需要一個面向列的數據文件,而不是面向行的數據文件。 如果是這種情況,則需要轉置它。 就像是:
my.ts = t(
read.delim(curFile, sep="\t", stringsAsFactors=FALSE,
header=FALSE, row.names=NULL,
fill=TRUE, quote="", comment.char="")
)
my.ts = ts(my.ts)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.