rowaggregate.DTSg | R Documentation |
Applies one or more provided summary functions row-wise to selected columns
of a DTSg
object.
## S3 method for class 'DTSg'
rowaggregate(
x,
resultCols,
fun,
...,
cols = self$cols(class = "numeric"),
clone = getOption("DTSgClone")
)
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. |
Returns a DTSg
object.
Some examples for fun
are as follows:
mean
list(min = min, max = max)
c(sd = "sd", var = "var")
cols
, getOption
# 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)
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.