# 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)
Run the code above in your browser using DataLab