Learn R Programming

PortfolioTesteR (version 0.1.4)

validate_group_map: 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)

Value

A two-column data.frame with columns Symbol and Group

(one row per symbol), sorted by Symbol.

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.

Examples

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

Run the code above in your browser using DataLab