用最近的gsubfn打破字符串插值?

enf*_*ion 5 debugging r string-interpolation gsub

最后一个例子用来工作,现在却没有.函数内部没有字符串插值?也许它与变量范围有关?有什么建议?

library(gsubfn)
#R.Version() # I'm using 2.15.0, just upgraded from 2.13.something.

### dumb example of a function
g <- function() {for (a in 1:2) { print(paste('is a', a)) }}
g()

### same thing, outside a function, using string interpolation
for (a in 1:2) { fn$print('is a $a') }
rm(a)

### and now string interpolation inside a function
h <- function() {for (a in 1:2) { fn$print('is a $a') }}
h()
Run Code Online (Sandbox Code Playgroud)

最后一个例子告诉我

Error in eval(expr, envir, enclos) : object 'a' not found
Run Code Online (Sandbox Code Playgroud)