validate_group_map: Validate a symbol-to-group mapping

View source: R/ml.R

validate_group_mapR Documentation

Validate a symbol-to-group mapping

Description

Normalizes and checks a symbol → group mapping for a given set of symbols. Accepts either a data.frame/data.table with columns Symbol and Group, or a named character vector c(symbol = "group", ...). Errors if any requested symbol is missing or mapped more than once.

Usage

validate_group_map(symbols, group_map)

Arguments

symbols

Character vector of symbols to validate/keep.

group_map

Data frame/data.table with columns Symbol,Group, or a named character vector mapping symbol -> group.

Value

A two-column data.frame with columns Symbol and Group (one row per symbol), sorted by Symbol.

Examples

validate_group_map(
  c("A","B"),
  data.frame(Symbol = c("A","B"), Group = c("G1","G1"))
)

PortfolioTesteR documentation built on Nov. 5, 2025, 5:23 p.m.