rowaggregate.DTSg {DTSg} | R Documentation |
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 |
resultCols |
A character vector either of length one (names of |
fun |
A summary function, (named) |
... |
Further arguments passed on to |
cols |
A character vector specifying the columns to apply |
clone |
A logical specifying if the object shall be modified in place or if a deep clone (copy) shall be made beforehand. |
Value
Returns a DTSg
object.
Summary functions
Some examples for fun
are as follows:
See Also
Examples
# new DTSg object
DT <- data.table::data.table(
date = flow$date,
flow1 = flow$flow - abs(rnorm(nrow(flow))),
flow2 = flow$flow,
flow3 = flow$flow + abs(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)
)$print()
## 'raggregate()' is a "hidden" R6 alias for 'rowaggregate()'
x$raggregate(
resultCols = "flow",
fun = list(mean = mean, sd = sd)
)$print()
## S3 method
print(rowaggregate(
x = x,
resultCols = "flow",
fun = list(mean = mean, sd = sd)
))