[R] colname of ... arguments

David Scott d.scott at auckland.ac.nz
Thu Mar 11 00:27:27 CET 2010


ManInMoon wrote:
> I have writtn a function where I pass a variable number of arguments.
> 
> I They are vectors and I can manipulate them, but I need to get hold of the
> name for a legend.
> 
> niceplot<-function(...) {
>    parms=list(...)
> 
>   for (x in parms) {
>     DoSomethingWith(x)
>   }
> 
> }
> 
> BUT how how can I get something like namestring(...) of nameofvector(x)?


I use the following syntax to get the name of a data object to use in a 
title, label or whatever.

xname <- paste(deparse(substitute(x), 500), collapse = "\n")

This is taken from hist.default so at least has some provenance as an 
appropriate method.

David Scott

-- 
_________________________________________________________________
David Scott	Department of Statistics
		The University of Auckland, PB 92019
		Auckland 1142,    NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email:	d.scott at auckland.ac.nz,  Fax: +64 9 373 7018

Director of Consulting, Department of Statistics



More information about the R-help mailing list