问题 我想创建一个 tsibble,但不清楚如何设置密钥以及如何设置索引。不是小标题。
我尝试了以下方法:
ts <- t %>%
as_tsibble(
key = t$key_field,
index = c(t$date, to$state),
regular = FALSE
)
但是得到了错误:
Error: Can't subset columns that don't exist.
x Columns `AA`, `AA`, `AA`, `AA`, =etc. don't exist.
There is NO columns named 'AA', this `AA`, `AA`, `AA`, `AA` is actually the data!
需要的示例 将欣赏从另一个现有 data.frame 源的数据收集创建的真实世界 tsibble。
讨论需要 讨论创建一个 tsibble 和定义一个索引,使用现有数据的键。我提供的代码抱怨
** 数据 **
地区 (chr)、州 (chr)、目的 (chr)、旅行 (dbl)、年份 (dbl)
1998 Q1 Adelaide South Australia Business 135.0776903 1998
1998 Q2 Adelaide South Australia Business 109.9873160 1998
1998 Q3 Adelaide South Australia Business 166.0346866 1998
1998 Q4 Adelaide South Australia Business 127.1604643 1998
1999 Q1 Adelaide South Australia Business 137.4485333 1999
1999 Q2 Adelaide South Australia Business 199.9125861 1999
1999 Q3 Adelaide South Australia Business 169.3550898 1999
1999 Q4 Adelaide South Australia Business 134.3579372 1999
2000 Q1 Adelaide South Australia Business 154.0343980 2000
2000 Q2 Adelaide South Australia Business 168.7763637 2000
2005 Q3 Australia's Coral Coast Western Australia Business 28.6365371 2005
2005 Q4 Australia's Coral Coast Western Australia Business 26.4668880 2005
2006 Q1 Australia's Coral Coast Western Australia Business 19.0804140 2006
2006 Q2 Australia's Coral Coast Western Australia Business 25.8851570 2006
2006 Q3 Australia's Coral Coast Western Australia Business 35.5701650 2006
2006 Q4 Australia's Coral Coast Western Australia Business 16.8853340 2006
2007 Q1 Australia's Coral Coast Western Australia Business 34.5039748 2007
2007 Q2 Australia's Coral Coast Western Australia Business 21.6070762 2007
2007 Q3 Australia's Coral Coast Western Australia Business 38.6497565 2007
2007 Q4 Australia's Coral Coast Western Australia Business 26.0811098 2007
这是另一个错误的尝试: