| aggregate_entity_values | R Documentation |
Aggregate one or more numeric values from entity-level records to a parent or group level. This can be used, for example, to average driver factors or sum premiums for boats or scheduled items.
aggregate_entity_values(
rated_entity_data,
group_col,
value_cols,
aggregation = "mean",
weight_col = NULL,
output_names = NULL,
output_prefix = NULL
)
rated_entity_data |
A data frame containing rated entity records. |
group_col |
A character string naming the column that identifies the parent or aggregation group. |
value_cols |
A character vector naming the numeric columns to aggregate. |
aggregation |
A character string specifying the aggregation method.
Supported values are |
weight_col |
An optional character string naming the weight column.
Required when |
output_names |
An optional character vector giving the names of the
aggregated output columns. It must have the same length as |
output_prefix |
An optional character string prepended to generated
output names when |
Common "sum", "mean", and "count" aggregations are performed in
grouped vectorized passes rather than repeatedly subsetting the entity data
once per parent group. Other supported aggregations reuse a single set of
precomputed group indices.
A data frame with one row per unique value of group_col and one
aggregated column for each entry in value_cols.
rated_drivers <- data.frame(
policy_id = c("P1", "P1", "P2"),
indicated_BI = c(1.10, 0.90, 1.05)
)
aggregate_entity_values(
rated_entity_data = rated_drivers,
group_col = "policy_id",
value_cols = "indicated_BI",
aggregation = "mean",
output_names = "average_BI"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.