我正在运行关于月度数据的时间序列,没有缺失值。无论我在哪一年设置“start = c”,我都会得到几个月/年的零值。
从2016年开始:
date< - as.Date(as ….
使用“小”数据子集,试试这个:
library(dplyr) library(tidyr) library(lubridate) library(R.utils) tidyr::separate(small, col = "YearMonth", into = c("Month", "Year")) %>% mutate(Month = R.utils::capitalize(tolower(Month))) %>% mutate(Day = "1") %>% select(Year, Month, Day, everything()) %>% unite(col = "Date", Year, Month, Day, sep = "-") %>% mutate(Date = lubridate::ymd(Date)) -> small2 timeseries <- ts(small2$OTIF, start = c(2007, 10), end = c(2008, 8), frequency = 12) plot(timeseries)