mapper: Make a mapper function

Description Usage Arguments Details Value Author(s)

View source: R/events.R

Description

Creates mapper function

Usage

1
mapper(lst, re = FALSE, unmatched = NULL)

Arguments

lst

A list of string to pattern associations

re

whether to treat the patterns as regular expressions

unmatched

what to return if there is no mapping (default NULL returns the original value)

Details

This function creates and returns a function which renames arguments or returns them unchanged if no mapping is provided. The function is initialised using a list describing the reverse mapping. For example, given list(a=c(1,2), b=3) a function is returned that turns 1 and 2 in 'a', 3 into 'b' and leaves all other arguments unchanged. When re is TRUE, name values are treated as regular expressions. In the returned function the base R function grepl is used to find the first matching argument. It has its default parameters: no PERL-style regexps, case sensitivity, and character rather than byte-based matching. When re is FALSE only exact matches trigger the mapping.

Value

A mapper function

Author(s)

Will Lowe


conjugateprior/events documentation built on May 13, 2019, 9:56 p.m.