| .fillDefaults {FindMyFriends} | R Documentation |
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
.fillDefaults(def)
def |
A named list of default values |
This function is called for its side effects
Set and get pangenome defaults with defaults
# 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)