时间序列中的数据与我输入的数据不同。如何获得与我的输入规模相似的输出?

The data in the time series is different from the data I entered. How do I get outputs in a similar scale as my inputs?

我有一列数据如下:

141523
146785
143667
65560
88524
148422
151664

。 . . .

我使用 ts() 函数将此数据转换为时间序列。

{ 

Aclines <- read.csv(file.choose())

Aclinests <- ts(Aclines[[1]], start = c(2013), end = c(2015), frequency = 52)

}

head(Aclines) 给我以下输出:

  X141.523
1  146785
2  143667
3   65560
4   88524
5  148422
6  151664

head(Aclinests) 给我以下输出:

 [1] 26 16 83 87 35 54

我所有进一步分析的输出(包括图表和预测)都按比例缩放到您如何查看 head(Aclinets) 输出。如何将输出缩放回原始数据的输入方式?将数据转换为 ts 时我遗漏了什么吗?

通常建议有一个可重现的例子How to make a great R reproducible example?。但我会尝试根据我正在阅读的内容提供帮助。如果没有帮助,我会删除 post.

首先,read.csv 默认为 header = TRUE。您的文件中似乎没有 header。此外,看起来 R 正在以因子而不是数字的形式读取数据。

因此您可以尝试使用几个参数来读取文件 -

Aclines <- read.csv(file.choose(), header=FALSE, stringsAsFactors=FALSE)  

然后得到你的时间序列

Aclinests <- ts(Aclines[, 2], start = c(2013), end = c(2015), frequency = 52)

由于您的数据看起来有 2 列,这会将数据框的第二列读入 ts object。

希望这对您有所帮助。