Convert to a control list.
as.control.list(x, ...)
# S3 method for class 'control.list'
as.control.list(x, ...)
# S3 method for class 'list'
as.control.list(x, FUN = NULL, unflat = TRUE, ...)An object, usually a list, to be converted to a
control list.
Additional arguments to methods.
Either a control.*() function or its name or suffix
(to which "control." will be prepended); defaults to taking the
nearest (in the call traceback) function that does not begin with
"as.control.list", and prepending "control." to it. (This is
typically the function that called as.control.list() in the
first place.)
Logical, indicating whether an attempt should be made to detect whether some of the arguments are appropriate for a lower-level control function and pass them down.
a control.list object.
as.control.list(control.list): Idempotent method for control lists.
as.control.list(list): The method for plain lists, which runs
them through FUN.
myfun <- function(..., control=control.myfun()){
as.control.list(control)
}
control.myfun <- function(a=1, b=a+1){
list(a=a,b=b)
}
myfun()
#> Error in vapply(lapply(sys.calls(), `[[`, 1L), as.character, character(1)): values must be length 1,
#> but FUN(X[[1]]) result is length 3
myfun(control = list(a=2))
#> Error in vapply(lapply(sys.calls(), `[[`, 1L), as.character, character(1)): values must be length 1,
#> but FUN(X[[1]]) result is length 3
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()
#> Error in vapply(lapply(sys.calls(), `[[`, 1L), as.character, character(1)): values must be length 1,
#> but FUN(X[[1]]) result is length 3
# 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))
#> Error in vapply(lapply(sys.calls(), `[[`, 1L), as.character, character(1)): values must be length 1,
#> but FUN(X[[1]]) result is length 3