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

时间:2012-06-24 21:09:07

标签: r debugging gsub string-interpolation

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

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

最后一个例子告诉我

Error in eval(expr, envir, enclos) : object 'a' not found

0 个答案:

没有答案