Minimum of specified columns by group
agg_min.Rd
Creates a Minimum aggregation that computes the minimum of each column in cols
for each aggregation group.
Value
AggOp
to be used in a call to agg_by()
or agg_all_by()
.
Details
The aggregation groups that this function acts on are defined with the by
parameter of the agg_by()
or
agg_all_by()
caller function. The aggregation groups are defined by the unique combinations of values in the by
columns. For example, if by = c("A", "B")
, then the aggregation groups are defined by the unique combinations of
values in the A
and B
columns.
This function, like other Deephaven agg
functions, is a generator function. That is, its output is another
function called an AggOp
intended to be used in a call to agg_by()
or agg_all_by()
. This detail is
typically hidden from the user. However, it is important to understand this detail for debugging purposes,
as the output of an agg
function can otherwise seem unexpected.
For more information, see the vignette on agg
functions by running
vignette("agg_by")
.
Examples
if (FALSE) { # \dontrun{
library(rdeephaven)
# connecting to Deephaven server
client <- Client$new("localhost:10000", auth_type = "psk", auth_token = "my_secret_token")
# create data frame, push to server, retrieve TableHandle
df <- data.frame(
X = c("A", "B", "A", "C", "B", "A", "B", "B", "C"),
Y = c("M", "N", "O", "N", "P", "M", "O", "P", "M"),
Number1 = c(100, -44, 49, 11, -66, 50, 29, 18, -70),
Number2 = c(-55, 76, 20, 130, 230, -50, 73, 137, 214)
)
th <- client$import_table(df)
# get minimum elements of Number1 and Number2
th1 <- th$
agg_by(agg_min(c("Number1", "Number2")))
# get minimum elements of Number1 and Number2 grouped by X
th2 <- th$
agg_by(agg_min(c("Number1", "Number2")), by = "X")
# get minimum elements of Number1 and Number2 grouped by X and Y
th3 <- th$
agg_by(agg_min(c("Number1", "Number2")), by = c("X", "Y"))
client$close()
} # }