Skip to content
Prev 201887 / 398506 Next

Force a variable substitution in expression

On 27/11/2009 11:04 AM, Saptarshi Guha wrote:
The substitute() function can do it, but the bquote() function is the 
most convenient:

 > foo <- function(s) {
+   bquote(expression({
+    v <- .(s)
+    print(v)
+   }))
+ }
 > foo(10)
expression({
    v <- 10
    print(v)
})

Duncan Murdoch