tapply: Apply a Function Over a time properties

tapplyR Documentation

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

  ## S4 method for signature 'TimeIntervalDataFrame,TimeIntervalDataFrame'
tapply(X, INDEX, FUN, ...,
       min.coverage=1, weights.arg=NULL, merge.X=TRUE, split.X=FALSE,
       keep.INDEX=TRUE,default=NA, simplify=TRUE)

  ## S4 method for signature 'TimeIntervalDataFrame,POSIXctp'
tapply(X, INDEX, FUN, ...,
       min.coverage=1, weights.arg=NULL, merge.X=TRUE, split.X=FALSE,
      default=NA, simplify=TRUE)

  ## S4 method for signature 'TimeIntervalDataFrame,POSIXcti'
tapply(X, INDEX, FUN, ...,
       min.coverage=1, weights.arg=NULL, merge.X=TRUE, split.X=FALSE,
      default=NA, simplify=TRUE)

Arguments

X

a TimeIntervalDataFrame or a TimeInstantDataFrame

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’.

default

argument inherited from the base function, currently unused; see tapply.

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 allowed). When a function (FUN) has a na.rm argument, the na.rm=TRUE behaviour is met if na.rm is set to TRUE and min.coverage to 0 (zero) ; the na.rm=FALSE behaviour is met if na.rm is set to FALSE whatever is the value of min.coverage. If min.coverage is set to NA, time coverage of the resulting interval is not checked. Moreover, overlapping of X intervals is not checked. Thus the aggregation is done according to ‘weights.arg’ argument (if given).

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.

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.

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.

See Also

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


timetools documentation built on Aug. 29, 2023, 5:09 p.m.