deparse
如果我这样做,我希望能够使用该功能
g = function(x) deparse(substitute(x))
那么就可以了
R) g(test)
[1] "test"
但是如果我想测试的论点g
是否是character
h = function(x) {if(is.character(x)){return(x)}; deparse(substitute(x))}
R) h(test)
Error in h(test) : object 'test' not found
为什么会发生这种情况,我可以修复它吗?
编辑:转载自新R --vanilla
R version 2.15.2 (2012-10-26)
Platform: i386-w64-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United Kingdom.1252
[2] LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base