Learn R Programming

DTSg (version 0.2.0)

colapply.DTSg: Apply Function Columnwise

Description

Applies an arbritary function to selected columns of a DTSg object.

Usage

# S3 method for DTSg
colapply(x, fun, ..., cols = self$cols(class =
  "numeric")[1L], clone = getOption("DTSgClone"))

Arguments

x

A DTSg object (S3 method only).

fun

A function. Its return value must be of length one.

Further arguments passed on to fun.

cols

A character vector specifying the columns to apply fun to.

clone

A logical specifying if the object is modified in place or if a clone (copy) is made beforehand.

Value

Returns a DTSg object.

Details

In addition to the argument, this method hands over a list argument with helper data called .helpers to fun. .helpers contains the following named elements:

  • .dateTime: A POSIXct vector containing the .dateTime column.

  • periodicity: Same as periodicity field. See DTSg for further information.

  • minLag: A difftime object containing the minimum time difference between two subsequent timestamps.

  • maxLag: A difftime object containing the maximum time difference between two subsequent timestamps.

See Also

DTSg, cols, list, POSIXct, difftime, interpolateLinear

Examples

Run this code
# NOT RUN {
# new DTSg object
x <- DTSg$new(values = flow)

# linear interpolation of missing values
## R6 method
x$colapply(fun = interpolateLinear)

## S3 method
colapply(x = x, fun = interpolateLinear)

# }

Run the code above in your browser using DataLab