myfun <- function(..., control=control.myfun()){
as.control.list(control)
}
control.myfun <- function(a=1, b=a+1){
list(a=a,b=b)
}
myfun()
myfun(control = list(a=2))
myfun2 <- function(..., control=control.myfun2()){
as.control.list(control)
}
control.myfun2 <- function(c=3, d=c+2, myfun=control.myfun()){
list(c=c,d=d,myfun=myfun)
}
myfun2()
# Argument to control.myfun() (i.e., a) gets passed to it, and a
# warning is issued for unused argument e.
myfun2(control = list(c=3, a=2, e=3))
Run the code above in your browser using DataLab