R: 访问 "msts" 对象的 "start" 属性
R: Accessing "start" attribute of "msts" object
我创建了一个这样的 msts
对象:
y <- msts(1:100, start=c(1,4), ts.frequency=6, seasonal.periods=c(6,12,50))
调用时显示其内容,包括start
参数:
> head(y)
Multi-Seasonal Time Series:
Start: 1 4
Seasonal Periods: 6 12 50
Data:
[1] 1 2 3 4 5 6
然而,start
不能被视为一个属性:
> attributes(y)
$tsp
[1] 1.5 18.0 6.0
$class
[1] "msts" "ts"
$msts
[1] 6 12 50
我的问题是,如何获取存储在 y
中的 start
向量 c(1,4)
?
?msts
表明 start 参数是 ts
class
的一个属性
Arguments to be passed to the underlying call to ts(). For example start=c(1987,5).
?ts
的“另见”部分提到了 ts
对象的打印方法。 start
就是其中之一。
这似乎给了你你想要的:
> library(forecast)
> y <- msts(1:100, start=c(1,4), ts.frequency=6, seasonal.periods=c(6,12,50))
> start(y)
[1] 1 4
我创建了一个这样的 msts
对象:
y <- msts(1:100, start=c(1,4), ts.frequency=6, seasonal.periods=c(6,12,50))
调用时显示其内容,包括start
参数:
> head(y)
Multi-Seasonal Time Series:
Start: 1 4
Seasonal Periods: 6 12 50
Data:
[1] 1 2 3 4 5 6
然而,start
不能被视为一个属性:
> attributes(y)
$tsp
[1] 1.5 18.0 6.0
$class
[1] "msts" "ts"
$msts
[1] 6 12 50
我的问题是,如何获取存储在 y
中的 start
向量 c(1,4)
?
?msts
表明 start 参数是 ts
class
Arguments to be passed to the underlying call to ts(). For example start=c(1987,5).
?ts
的“另见”部分提到了 ts
对象的打印方法。 start
就是其中之一。
这似乎给了你你想要的:
> library(forecast)
> y <- msts(1:100, start=c(1,4), ts.frequency=6, seasonal.periods=c(6,12,50))
> start(y)
[1] 1 4