View source: R/aggregateDays2Weeks.R
aggregateDays2Weeks | R Documentation |
An either univariate or multivariate time series consisting of Time
of many Days over several years, and Data
is aggregated to weeks.
aggregateDays2Weeks(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 |
A week is defined here by the ISO 8601 system, which uses a reoccurring leap week.
Especially this means that every week starts with mondays and all values from monday to sunday are aggreagted to monday. In other words, a time stamp returned by this function has all values aggregated starting from the time stamp until the 7th day (a sunday) in advance.
If the timeseres does not begin with a monday, all values before monday are aggregated to the monday before the first monday of the time series. The internal functions of R doing this aggregation assume a regular daily time series. If this is not the case, a warning is given back and a regular time series is generated using GenerateRegularDailyTS
with the Parameter na.rm='zero'
. Depending on the aggregation function FUN
it could result in an incorrect aggregation.
Aggegation works even if several different years are used.
Dataframe[1:m,1:(d+1)] with m<n, where m are the number of wees, and the first column beeing the time in as.Date
format.
If the error "no rows to aggregate" arrises, it may be beause the data contains nans. in such a case add
na.rm=TRUE
and na.action=na.pass
to the function input parameters.
Michael Thrun
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.