Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R从hts()的归一化数据.frame创建多元时间序列矩阵_R_Time Series - Fatal编程技术网

R从hts()的归一化数据.frame创建多元时间序列矩阵

R从hts()的归一化数据.frame创建多元时间序列矩阵,r,time-series,R,Time Series,我有一个data.frame,它有3列: telar <- data.frame( class = c("A","B","A","B"), date = as.Date(c("2019-01-01", "2019-01-01", "2019-02-01", "2019-02-01")), number = c(10, 20, 11, 21) ) telar nodes <- list(length(unique(telar))) ## Here something t

我有一个data.frame,它有3列:

 telar <- data.frame(
  class = c("A","B","A","B"),
  date = as.Date(c("2019-01-01", "2019-01-01", "2019-02-01", "2019-02-01")),
  number = c(10, 20, 11, 21)
)
telar
nodes <- list(length(unique(telar)))
## Here something to create the new time series matrix
my_hts <- hts(new_time_series_matrix, nodes)
new_time_series_matrix <- ts(
  select(
    dcast(telar, date ~ class), -date
  ),
  start=c(year(telar$date[1]), month(telar$date[1])), 
  frequency = 12
)
new_time_series_matrix
          A  B
Jan 2019 10 20
Feb 2019 11 21