[R] Force a variable substitution in expression

Saptarshi Guha saptarshi.guha at gmail.com
Fri Nov 27 17:29:39 CET 2009


> 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
>

Thanks, after sending this email, i used substitute, but first eval'ing
the formals (since they are delayed assignments).
I see bquote does this for me.


Regards
Saptarshi




More information about the R-help mailing list