'ts' 对象中的错误必须有一个或多个观察结果

Error in 'ts' object must have one or more observations

我有一个问题 运行 这段代码,它总是显示这个错误:'ts' object must have one or more observations。

library('forecast')
library('tseries')
library('urca')


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

head(dataset_180days)

# Timeseries data 
Yts_180days=ts(dataset_180days$Actual) #used to create time-series objects.

# ^--- this is where the error occurs.

# Augmented Dickey-Fuller Test Unit Root / Cointegration Test 
udf_test_180days <- ur.df(Yts_180days) #computes the augmented Dickey-Fuller test
summary(udf_test_180days)

# Ljung-Box Test
LB_test_180days <- Box.test(Yts_180days, type='Ljung-Box') # test statistic for examining the null hypothesis of independence in a given time series
print(LB_test_180days)

# Augmented Dickey-Fuller (ADF) t-test

adf_test_180days <- adf.test(Yts_180days,alternative = 'stationary')
print(adf_test_180days)

谢谢

附件请查收数据集

https://www.dropbox.com/s/1cmwf4dema1jemw/January-2012.csv?dl=0

我回到这里 post 解决方案! 好吧,因为我更改了数据集,所以我只需更改代码中变量 "Actual" 的名称;)