Learn R Programming

events (version 0.5)

make_fun_from_list: Create a mapping function from list

Description

Creates a mapping function from list

Usage

make_fun_from_list(lst)

Arguments

lst
A list

Value

A function that inverts the mapping specified by lst

Details

Turns a list of the form list(a=c(1,2), b=3) into a function that returns 'a' when given 1 or 2 as argument, 'b' when given 3 and otherwise gives back its argument unchanged.

This is a convenience function to make it possible to specify onto mappings using lists. The map_* functions use it internally, but you might find a a use for it.