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)? -- View this message in context: http://n4.nabble.com/colname-of-arguments-tp1588146p1588146.html Sent from the R help mailing list archive at Nabble.com.
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
I think you need to provide a richer example: niceplot<-function(...) { parms=list(...) for (x in parms) { cat(x) } } > e="e" > niceplot(e) e On Mar 10, 2010, at 5:21 PM, 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)? > -- > View this message in context: http://n4.nabble.com/colname-of-arguments-tp1588146p1588146.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.