what about:

niceplot<-function(...) {
arg.names <- as.list (match.call () [-1])
for (a in seq_along (arg.names))
 cat (as.character (as.expression (arg.names [[a]])), "\n\n")
}

niceplot (greeneye, log (greeneye), 1:3)

note that this works also if there is no "greeneye"

Disclaimer: I don't know whether I'm suggesting something bad, but I'd like to learn about better ways. So I really appreciate comments.

Claudia

ManInMoon wrote:
That is quite helpful David

niceplot<-function(...) {
 parms=list(...)
 for (x in parms) {
 xname <- paste(deparse(substitute(x), 500), collapse = "\n")
   cat(xname)
 }
}

GreenEyes=c(1,2,3,4)
niceplot(GreenEyes)
c(1, 2, 3, 4)

BUT what I want is:
 > GreenEyes=c(1,2,3,4)
niceplot(GreenEyes)
"GreenEyes"

I will use the vector for plotting too, but I need it's name to produce a
legend automatically




On 10 March 2010 23:32, David Scott-6 [via R] <
ml-node+1588213-620034400-180...@n4.nabble.com<ml-node%2b1588213-620034400-180...@n4.nabble.com>
wrote:

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: [hidden 
email]<http://n4.nabble.com/user/SendEmail.jtp?type=node&node=1588213&i=0>,
 Fax: +64 9 373 7018

Director of Consulting, Department of Statistics

______________________________________________
[hidden 
email]<http://n4.nabble.com/user/SendEmail.jtp?type=node&node=1588213&i=1>mailing
 list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
and provide commented, minimal, self-contained, reproducible code.


------------------------------
 View message @
http://n4.nabble.com/colname-of-arguments-tp1588146p1588213.html
To unsubscribe from colname of ... arguments, click here< (link removed) ==>.






--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 0 40 5 58-37 68
email: cbelei...@units.it

______________________________________________
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