After some more digging (grep alist R-devel/ ), I've come up with this,
tools:::as.alist.symbol(x)
sugar = function(fun, id = id){
ff - formals(fun)
if( id %in% names(ff))
stop(paste(id, is part of args(fun)))
new.arg - tools:::as.alist.symbol(id)
formals(fun) - c(unlist(ff), new.arg)
Dear list,
I have the following function,
sugar = function(fun, id = id){
ff - formals(fun)
if( id %in% names(ff))
stop(id is part of args(fun))
formals(fun) - c(unlist(ff), alist(id=))
fun
}
which one may use on a function foo,
foo = function(x){
x
}
sugar(foo) # results in the
2 matches
Mail list logo