join_entity_values: Join aggregated entity values to parent records

View source: R/entities.R

join_entity_valuesR Documentation

Join aggregated entity values to parent records

Description

Left-join aggregated entity-level values back to the parent-level rating data. When the entity-side join keys are unique and there are no overlapping non-key column names, a direct keyed match is used. More complicated joins fall back to base merge() to preserve general behavior.

Usage

join_entity_values(parent_data, entity_values, by)

Arguments

parent_data

A data frame containing parent-level records.

entity_values

A data frame containing aggregated entity values.

by

A character vector naming the column or columns used to join the two data frames.

Value

A data frame containing all rows from parent_data with matching columns from entity_values.

Examples

policies <- data.frame(
  policy_id = c("P1", "P2"),
  base_premium = c(100, 120)
)

driver_values <- data.frame(
  policy_id = c("P1", "P2"),
  average_driver_factor = c(1.05, 0.95)
)

join_entity_values(
  parent_data = policies,
  entity_values = driver_values,
  by = "policy_id"
)

ratingtables documentation built on Sept. 6, 2026, 1:06 a.m.