Skip to content
Prev 34736 / 63424 Next

A fix that for 'bquote' that may work (PR#14031)

On Thu, 5 Nov 2009, suharto_anggono at yahoo.com wrote:

            
If you want to use bquote() on function definitions a better fix is

bquote <- function (expr, where = parent.frame())
{
     unquote <- function(e) {
         if (length(e) <= 1)
             e
         else if (e[[1]] == as.name("."))
             eval(e[[2]], where)
         else if (is.pairlist(e)){
             as.pairlist(lapply(e,unquote))
         }
         else as.call(lapply(e, unquote))
     }
     unquote(substitute(expr))
}

since that now allows substitution into default arguments, eg
   default<-1
   g<-b2quote(function(x,y=.(default)) x+y )



         -thomas

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle