双周频率与 tibbletime 包

问题描述

我有一个每日商品价格的时间tibble数据集(package timbe tibble)

tbl.data

# A time tibble: 24 x 12
# Index: v.date
   v.date      cafe arroz   boi Ethanol Frango Milho  Soja Suino Trigo Algodao
   <date>     <dbl> <dbl> <dbl>   <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl>   <dbl>
 1 2013-01-02  336.  35.3  97.2   1194.   3.91  34.1  75.7  3.77  737.    158.
 2 2013-01-03  335.  35.0  97.7   1198.   3.98  33.9  75.7  3.77  746.    158.
 3 2013-01-04  338.  35.0  97.9   1196.   4.01  33.7  75.7  3.77  753.    161.
 4 2013-01-07  340.  34.9  97.9   1195    4.01  33.5  75.7  3.77  746.    163.
 5 2013-01-08  339.  34.4  97.0   1197    4.04  33.4  75.7  3.76  746.    165.
 6 2013-01-09  337.  34.5  97.6   1194.   3.96  33.2  75.7  3.76  756.    166.
 7 2013-01-10  338.  34.4  97.7   1196    3.96  32.9  75.7  3.76  760.    168.
 8 2013-01-11  341.  34.4  97.6   1192.   3.96  32.7  75.7  3.76  762.    170.
 9 2013-01-14  343.  34.4  97.4   1193    3.9   32.7  75.7  3.8   766.    172.
10 2013-01-15  347.  34.1  97.4   1193    3.9   32.4  75.7  3.8   769.    173.
# ... with 14 more rows,and 1 more variable: Berezzo <dbl>

使用 as_period 包中的 tibbletime 函数。我可以更改频率以获得每周数据。

tbl.data=as_period(tbl.data,'1 w')
# A time tibble: 420 x 12
# Index: v.date
   v.date      cafe arroz   boi Ethanol Frango Milho  Soja Suino Trigo Algodao
   <date>     <dbl> <dbl> <dbl>   <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl>   <dbl>
 1 2013-01-02  336.  35.3  97.2   1194.   3.91  34.1  75.7  3.77  737.    158.
 2 2013-01-07  340.  34.9  97.9   1195    4.01  33.5  75.7  3.77  746.    163.
 3 2013-01-14  343.  34.4  97.4   1193    3.9   32.7  75.7  3.8   766.    172.
 4 2013-01-21  349.  34.2  97.3   1202.   3.87  32.4  75.7  3.85  780.    180.
 5 2013-01-28  339.  34.4  97.5   1202.   3.84  32.0  63.6  3.8   774.    183.
 6 2013-02-04  334.  34.3  98.3   1236.   3.69  31.8  63.4  3.73  767.    183.
 7 2013-02-13  319.  34.3  98.2   1274.   3.81  32.9  64.6  3.73  755.    181.
 8 2013-02-18  311.  33.8  97.7   1306    3.9   32.3  64.6  3.75  755.    180.
 9 2013-02-25  309.  33.6  98.3   1314    3.95  32.4  63    3.73  745.    186.
10 2013-03-04  313.  32.5  97.7   1310.   3.76  32.4  62.4  3.77  747.    192.
# ... with 410 more rows,and 1 more variable: Berezzo <dbl>

但是,我想要每两周一次的数据。 有什么想法吗?

谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)