Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rowaggregate.DTSg

Aggregate Values Row-wise


Description

Applies one or more provided summary functions row-wise to selected columns of a DTSg object.

Usage

## S3 method for class 'DTSg'
rowaggregate(
  x,
  resultCols,
  fun,
  ...,
  cols = self$cols(class = "numeric"),
  clone = getOption("DTSgClone")
)

Arguments

x

A DTSg object (S3 method only).

resultCols

A character vector either of length one (names of fun are appended in the case one or more functions are provided) or the same length as fun.

fun

A summary function, (named) list of summary functions or (named) character vector specifying summary functions applied row-wise to all the values of the specified columns. The return value(s) must be of length one. See details for further information.

...

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.

Details

Some examples for fun are as follows:

A list or character vector must have names in case more than one summary function is provided.

Value

Returns a DTSg object.

See Also

Examples

# new DTSg object
DT <- data.table::data.table(
  date = flow$date,
  flow1 = flow$flow - rnorm(nrow(flow)),
  flow2 = flow$flow,
  flow3 = flow$flow + rnorm(nrow(flow))
)
x <- DTSg$new(values = DT)

# mean and standard deviation of multiple measurements per timestamp
## R6 method
x$rowaggregate(resultCols = "flow", fun = list(mean = mean, sd = sd))

## S3 method
rowaggregate(x = x, resultCols = "flow", fun = list(mean = mean, sd = sd))

DTSg

A Class for Working with Time Series Based on 'data.table' and 'R6' with Largely Optional Reference Semantics

v0.7.0
MIT + file LICENSE
Authors
Gerold Hepp [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.