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 extended closure, function (x, id) { x } Its limitation (other than not working with .Primitives) is the 'id' tag that I add in the formals of fun(). I don't know how to create a alist(id=) pairlist where id can be changed. I tried the usual bquote and substitute approach but they don't seem to work here. I suppose I could do something like, parse(text = paste("alist(",id, "=)", sep="")) but this is usually not recommended. Any ideas? Best regards, baptiste ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.