Hi Charles,

Charles C. Berry wrote:
> Try this:
> 
>       f2 <- function(...)  sapply( substitute(list(...)), deparse )[-1]

Wow, this works. Thanks a lot!

> p.s. Why do you want this as mode "character"? 

For the usual purpose of 'substitute': to label something. The use case
is that I have a function that takes an unspecified number of very large
integer vectors which are visualized in some way. I first tried to pass
all the vectors as one list, via '.Call', but that made R duplicate the
vectors, when the list argument is built. So, I now use '...' and
'.External', where duplication does not happen. I would like to
conveniently label the vectors by the expression with which they have
been passed (as 'plot' does, too), and with your construction, I can now
extract the expressions as characters and pass them to make the labels.

> Warning:
> 
>> fortune(106)
> 
> If the answer is parse() you should usually rethink the question.
>     -- Thomas Lumley
>        R-help (February 2005)

Then, I am lucky that you offered a solution with 'deparse', not
'parse'. ;-) Still, I am (pleasently) surprised that the vectors within
the '...' do not get duplicated (according to 'tracemem') by this
construction.

Thank you very much
   Simon

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to