aggregateWeeks2FiskalMonths: Aggregate Weeks to Fiskal Months

View source: R/aggregateWeeks2FiskalMonths.R

aggregateWeeks2FiskalMonthsR Documentation

Aggregate Weeks to Fiskal Months

Description

Aggregation of many weeks over several years to fiskal months is possible. A fiskal month is defined by the following. Every first month in a quarter has five weeks the following two months have exactly four weeks. The first month in the year starts with a monday (and every following month). A month has only full weeks included in it.

Usage

aggregateWeeks2FiskalMonths(Time,Data,FUN,Header, ...)

Arguments

Time

[1:n] vector of as.Date object. Beware, weekly data beginning with always monday is expected!

Data

[1:n,1:d] matrix or dataframe, d can be also 1, then vector

FUN

aggegate by a function like sum or mean

Header

colnames for data

...

further arguments passed on to FUN

Details

The rownames of the data frame depict either the first week (usually) of the month the data is aggregated by or, in the case of the first time interval until a full month of data exists, the last week where data was existed (see example). The fiskal month is often used to compare weekly and monthly forecasts consistently.

Value

dataframe[1:m,1:(d+1)] with m<n and first column beeing the time in as.Date format

Author(s)

Michael Thrun

Examples

#Generating Data
data(Sales)
Time=seq(from=as.Date('1970-01-01'),by='1 day',length.out = 2*length(Sales))
#Aggregation
Monthly=aggregateDays2FiskalMonths(Time,c(Sales,Sales),sum)
str(Monthly)

Mthrun/TSAT documentation built on Feb. 5, 2024, 11:15 p.m.