Package 'listWithDefaults'

Title: List with Defaults
Description: Provides a function that, as an alternative to base::list, allows default values to be inherited from another list.
Authors: Russell S. Pierce
Maintainer: Russell S. Pierce <[email protected]>
License: GPL-2
Version: 1.2.0
Built: 2024-11-14 06:15:15 UTC
Source: https://github.com/russellpierce/listwithdefaults

Help Index


listWithDefaults

Description

Takes arguments as base::list to create a list. If any arguments are present in defaultList, but absent in ..., then the values from defaultList are used.

Usage

listWithDefaults(..., defaultList = NULL)

Arguments

...

objects, must be named; alternatively a single argument may be provided in this position as a named list

defaultList

a named list containing the default values

Note

Argument order is not controlled. Non-default arguments come first in the order specified followed by all default arguments.

Examples

listWithDefaults(defaultList=list(a=2,b=2))
listWithDefaults(a=1,defaultList=list(a=2,b=2))
listWithDefaults(b=1,defaultList=list(a=2,b=2))
listWithDefaults(a=1,b=1,defaultList=list(a=2,b=2))
listWithDefaults(list(a=1),defaultList=list(a=2,b=2))