One option is to combine eval and bquote .
makeFn <- function(k) { eval(bquote(function(n) rep(.(k),n))) } five <- makeFn(5) body(five) # rep(5, n)
The notation .() Tells bquote to evaluate everything in the parenthesis and then include the result in the expression.
dayne source share