.fillDefaults {FindMyFriends}R Documentation

Assign object defaults to missing values

Description

This function takes care of investigating the enclosing functions arguments and identifying the missing ones. If they are missing and a default is given this value is assigned to the enclosing functions environment

Usage

.fillDefaults(def)

Arguments

def

A named list of default values

Value

This function is called for its side effects

See Also

Set and get pangenome defaults with defaults

Examples

# Should only be called within methods/functions

# This will obviously fail
## Not run: 
  t <- function(x) {
    x+1
  }
  t()

## End(Not run)

# Using .fillDefaults
t <- function(x, defs) {
  .fillDefaults(defs)
  x+1
}

# With defaults
t(defs=list(x=5))

# Direct setting takes precedence
t(x=2, defs=list(x=5))

# Still fails if defs doesn't contain the needed parameter
## Not run: 
  t(defs=list(y='no no'))

## End(Not run)

# Usually defs are derived from the object in a method:
## Not run: 
  setMethod('fillDefExample', 'pgFull',
    function(object, x, y) {
      .fillDefaults(defaults(object))
      x+y
    }
  )

## End(Not run)


[Package FindMyFriends version 1.18.0 Index]