Skip to contents

Extract value for a named list or use default if key is missing

Usage

option_or_default(options, key, default)

Arguments

options

Named list

key

String key

default

Default value to be returned, if key is missing.

Value

Value from a list or default value

Examples

option_or_default(list("A" = 25), "A", 20)
#> [1] 25
option_or_default(list("A" = 25), "B", 20)
#> [1] 20