grapes-map-grapes: %map%: Case-insensitive mapping returning named vector

%map%R Documentation

%map%: Case-insensitive mapping returning named vector

Description

Performs case-insensitive matching between elements in x and entries in table, returning a named character vector: names are the matched entries from table, values are the original elements from x. Unmatched values are ignored (not included in the result).

Usage

x %map% table

Arguments

x

Character vector of input strings.

table

Character vector to match against.

Value

A named character vector. Names are from matched table values, values are from x. If no matches are found, returns a zero-length named character vector.

Examples

# Basic matching (case-insensitive)
c("tp53", "brca1", "egfr") %map% c("TP53", "EGFR", "MYC")
# returns: Named vector: TP53 = "tp53", EGFR = "egfr"

# Values not in table are dropped
c("akt1", "tp53") %map% c("TP53", "EGFR")
# returns: TP53 = "tp53"

# All unmatched values returns: empty result
c("none1", "none2") %map% c("TP53", "EGFR")
# returns: character(0)

evanverse documentation built on March 10, 2026, 5:07 p.m.