Learn R Programming

timetools (version 1.5.2)

tapply: Apply a Function Over a time properties

Description

Apply a function over a Time*DataFrame that is first splitted into several sets according to time properties specified by INDEX.

Usage

## S3 method for class 'TimeIntervalDataFrame,TimeIntervalDataFrame':
tapply(X, INDEX, FUN, ...,
       min.coverage=1, weights.arg=NULL, merge.X=TRUE, split.X=FALSE,
       keep.INDEX=TRUE, simplify=TRUE)

## S3 method for class 'TimeIntervalDataFrame,POSIXctp': tapply(X, INDEX, FUN, ..., min.coverage=1, weights.arg=NULL, merge.X=TRUE, split.X=FALSE, simplify=TRUE)

## S3 method for class 'TimeIntervalDataFrame,POSIXcti': tapply(X, INDEX, FUN, ..., min.coverage=1, weights.arg=NULL, merge.X=TRUE, split.X=FALSE, simplify=TRUE)

Arguments

INDEX
an object corresponding to or containing a time properties. Classes available depend on X. See sections below to know all (X, INDEX) combination defined.
FUN
the function to be applied.
...
optional arguments to 'FUN'.
simplify
if FALSE a list of Time*DataFrame is returned ; if TRUE tapply try to reduce the list to a single Time*DataFrame.
min.coverage
a numeric between 0 and 1 indicating the percentage of valid values over each interval to allow an aggregation. NA is returned if the percentage is not reach. In that configuration (min.coverage between 0 and 1, overlapping intervals are not allow
weights.arg
if FUN has a weight argument, this parameter must be a character naming the weight argument. For instance, if FUN is weighted.mean, then weights.arg is 'w'.
merge.X
logical indicating if data in X can be merged over interval of the new time support.
split.X
logical indicating if data in X that are over several intervals of 'INDEX' must be 'cut' to fit to new intervals (TRUE) or ignored (FALSE).
keep.INDEX
logical indicating if INDEX values must be kept on the resulting list.

signature(TimeIntervalDataFrame, TimeIntervalDataFrame)

split TimeIntervalDataFrame over another TimeIntervalDataFrame and then apply a function over each elements of the list.

signature(TimeIntervalDataFrame, POSIXctp)

split a TimeIntervalDataFrame against regular time intervals with a period defined by INDEX (a POSIXctp). Then a function is applied over each elements of the list.

signature(TimeIntervalDataFrame, POSIXcti)

split TimeIntervalDataFrame against specified intervals (POSIXcti). and then apply a function over each elements of the list.

Details

These functions are equivalent to old changeSupport methods. Instead of having the core splitting algorithm in it, it uses the split methods. Be aware that default parametres values between the two families (changeSupport and tapply) are not necessarily the same.

Users are encouraged to use tapply instead of changeSupport since new versions of changeSupport are only wrappers to tapply.

See Also

tapply, TimeIntervalDataFrame-class, TimeInstantDataFrame-class, SubtimeDataFrame-class, changeSupport, POSIXcti-class, POSIXst-class, POSIXctp-class