check_list_mapping: Check if two named list are compatible to merge

View source: R/platform.R

check_list_mappingR Documentation

Check if two named list are compatible to merge

Description

To be compatible with template, mapping should follow these rules:

  • only one value is mapped to a name

  • new can add new name with new value, not already in old

  • new cannot redefine a value with a new name (unless allow_override, not currently supported)

Usage

check_list_mapping(new, old, raise, only.errors = TRUE)

Arguments

new

list()

old

list()

raise

function(type, value, problem, message)

only.errors

only raise errors

Details

Overriding is allowed wraping the value with override function

Examples

## Not run: 
new = list("var1"="Q1", "var2"="Q2", "var3"="Q3", "var4"="Q1", "var5"="Q4")
old = list("var0"="Q0", "var1"="Q1", "var2"="Q4")
check_list_mapping(new, old, raise=raise)
# Returs list of errors

new = list("var1"="Q1", "var3"=override("Q2"))
old = list("var2"="Q2")
check_list_mapping(new, old, raise=raise) # Only throw warning

## End(Not run)
# The checks are transmitted to a provided function \code{\link{raise()}}

cturbelin/ifnBase documentation built on Nov. 5, 2023, 12:54 p.m.