[R] dots and substitute
anders at ebi.ac.uk
Sun Apr 6 23:51:48 CEST 2008
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.
> 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
Thank you very much
More information about the R-help