View source: R/aggregateWeeks2FiskalMonths.R
aggregateWeeks2FiskalMonths | R Documentation |
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.
aggregateWeeks2FiskalMonths(Time,Data,FUN,Header, ...)
Time |
[1:n] vector of |
Data |
[1:n,1:d] matrix or dataframe, d can be also 1, then vector |
FUN |
aggegate by a function like |
Header |
colnames for data |
... |
further arguments passed on to |
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.
dataframe[1:m,1:(d+1)] with m<n and first column beeing the time in as.Date
format
Michael Thrun
#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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.