to_weekly: Change a daily to a weekly differenced time series

Description Usage Arguments Author(s) Examples

View source: R/to_weekly.R

Description

This function computes the weekly aggregates or differences (by default Friday to Friday) for any daily time series in the xts format.

Usage

1
to_weekly(x, incl_forecast = T, forecast_length = 365, diff = T, dayofweek = 5)

Arguments

x

input series

incl_forecast

whether the series contains a forecast that shall be omitted

forecast_length

length of forecast

diff

should series be differenced

dayofweek

which day of the week (friday=5)

Author(s)

Daniel Ollech

Examples

1
to_weekly(xts::xts(rnorm(365, 10,1), seq.Date(as.Date("2010-01-01"), length.out=365, by="days")))

Example output

                  [,1]
2010-01-01          NA
2010-01-08  0.51491543
2010-01-15 -0.22732670
2010-01-22 -0.08381238
2010-01-29 -1.52056981
2010-02-05  1.01965300
2010-02-12 -1.99787778
2010-02-19  1.61488297
2010-02-26 -3.02035085
2010-03-05  2.81552833
2010-03-12  0.13977097
2010-03-19 -0.82134264
2010-03-26  1.92832349
2010-04-02 -0.34651505
2010-04-09 -1.80002687
2010-04-16  1.47415712
2010-04-23 -1.12859632
2010-04-30  1.26211202
2010-05-07  1.18093134
2010-05-14 -2.43655714
2010-05-21 -0.16484631
2010-05-28 -0.99446567
2010-06-04  1.37574646
2010-06-11  0.52373714
2010-06-18  1.94243325
2010-06-25 -2.36806759
2010-07-02 -0.15581113
2010-07-09  0.35069205
2010-07-16  0.84724601
2010-07-23 -1.30307586
2010-07-30  2.45938434
2010-08-06 -1.75155178
2010-08-13 -0.62053093
2010-08-20  1.34186419
2010-08-27 -0.62411739
2010-09-03 -1.11336006
2010-09-10 -0.69877754
2010-09-17  2.73709382
2010-09-24 -0.38035139
2010-10-01 -0.36677954
2010-10-08 -1.30401819
2010-10-15  1.05938257
2010-10-22 -0.26808088
2010-10-29 -0.23871395
2010-11-05  1.58086609
2010-11-12 -0.11794315
2010-11-19  2.00413573
2010-11-26 -3.38873160
2010-12-03  0.20108190
2010-12-10  1.34062016
2010-12-17 -2.23147840
2010-12-24 -0.38643407
2010-12-31  2.85671626

dsa documentation built on June 21, 2021, 9:07 a.m.