aggregateDays2Weeks: Aggregate Days to Weeks

View source: R/aggregateDays2Weeks.R

aggregateDays2WeeksR Documentation

Aggregate Days to Weeks

Description

An either univariate or multivariate time series consisting of Time of many Days over several years, and Data is aggregated to weeks.

Usage

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

Arguments

Time

[1:n] vector of POSIXlt or POSIXct or as.Date objects

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

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.

Value

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.

Note

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.

Author(s)

Michael Thrun


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