Generates a weight table by parsing comma-separated Flag and RiskScoreWeight values from a metrics metadata data frame. This table can be joined to KRI results to add weight information for risk score calculations.
Value
`data.frame` Weight table with one row per MetricID-Flag combination, containing:
- MetricID
Unique metric identifier
- Flag
Individual flag value (numeric)
- Weight
Weight associated with the flag (numeric)
- WeightMax
Maximum weight for the metric (numeric)
Details
The function performs the following steps:
Filters to rows with non-NA Flag and RiskScoreWeight values
Splits comma-separated Flag and RiskScoreWeight strings into lists
Expands to one row per flag-weight combination
Converts Flag and Weight to numeric values
Calculates WeightMax as the maximum Weight per MetricID
Examples
# Create weight table from gsm.core::reportingMetrics
dfWeights <- MakeWeights(gsm.core::reportingMetrics)
# Join to KRI results
library(dplyr)
dfResults <- gsm.core::reportingResults %>%
left_join(dfWeights, by = c("MetricID", "Flag"))