[R] How to extract function arguments literally

Duncan Murdoch murdoch at stats.uwo.ca
Sat Apr 30 08:26:22 CEST 2005


Shigeru Mase wrote:

> But, if it has no quotation marks or contains spaces, it yileds an error.
> 
> 
>>as.character(substitute((def x1 x2))
> 
> 
> Error: syntax error
> 
> He wants to use the syntax like lc((def x1 x2)), not like
> lc("(def x1 x2)").

No, that wouldn't be possible.  Since lc((def x1 x2)) is not legal S 
language, the parser is going to complain about it.  The only solution 
here would be to parse the whole thing yourself (i.e. parse the R 
source), rather than using the R parser.

Duncan Murdoch




More information about the R-help mailing list