Hi, all! I want to give an object to a function and use the NAME of this object inside the function to build new objects based on this name. How do I get the name of an object if I don't pass a string containing the name but the object itself? Christoph. -- Christoph Lange MPI fuer biologische Kybernetik |Phone: +49-7071-601-607| Postfach 2169, D-72012 Tuebingen |FAX: +49-7071-601-616|
You probably want deparse(substitute(object)) See ?substitute.> -----Original Message----- > From: Christoph Lange [mailto:christoph.lange at tuebingen.mpg.de] > Sent: 10 November 2003 16:06 > To: R Help List > Subject: [R] Finding the name ob an object > > > Security Warning: > If you are not sure an attachment is safe to open please contact > Andy on x234. There are 0 attachments with this message. > ________________________________________________________________ > > > Hi, all! > > I want to give an object to a function and use the NAME of this object > inside the function to build new objects based on this name. > > How do I get the name of an object if I don't pass a string containing > the name but the object itself? > > Christoph. > > -- > Christoph Lange > MPI fuer biologische Kybernetik |Phone: +49-7071-601-607| > Postfach 2169, D-72012 Tuebingen |FAX: +49-7071-601-616| > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help >Simon Fear Senior Statistician Syne qua non Ltd Tel: +44 (0) 1379 644449 Fax: +44 (0) 1379 644445 email: Simon.Fear at synequanon.com web: http://www.synequanon.com Number of attachments included with this message: 0 This message (and any associated files) is confidential and\...{{dropped}}
Look at the first lines of plot.default for an example of how to extract the name of an argument. HTH, Giovanni> Date: Mon, 10 Nov 2003 17:06:17 +0100 > From: Christoph Lange <christoph.lange at tuebingen.mpg.de> > Sender: r-help-bounces at stat.math.ethz.ch > Mail-followup-to: R Help List <r-help at stat.math.ethz.ch> > Precedence: list > User-Agent: Mutt/1.4.1i-nntp > > > Hi, all! > > I want to give an object to a function and use the NAME of this object > inside the function to build new objects based on this name. > > How do I get the name of an object if I don't pass a string containing > the name but the object itself? > > Christoph. > > -- > Christoph Lange > MPI fuer biologische Kybernetik |Phone: +49-7071-601-607| > Postfach 2169, D-72012 Tuebingen |FAX: +49-7071-601-616| > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > >-- __________________________________________________ [ ] [ Giovanni Petris GPetris at uark.edu ] [ Department of Mathematical Sciences ] [ University of Arkansas - Fayetteville, AR 72701 ] [ Ph: (479) 575-6324, 575-8630 (fax) ] [ http://definetti.uark.edu/~gpetris/ ] [__________________________________________________]
> f <- function(x)deparse(substitute(x))> f(pi) [1] "pi" answer the question? spencer graves Christoph Lange wrote:>Hi, all! > >I want to give an object to a function and use the NAME of this object >inside the function to build new objects based on this name. > >How do I get the name of an object if I don't pass a string containing >the name but the object itself? > >Christoph. > > >
Christoph Lange wrote:> Hi, all! > > I want to give an object to a function and use the NAME of this object > inside the function to build new objects based on this name. > > How do I get the name of an object if I don't pass a string containing > the name but the object itself?deparse(substitute(x)) Uwe Ligges
On 10 Nov 2003 at 17:06, Christoph Lange wrote:> test <- function(x){+ return(substitute(x))}> a <- 3 > test(a)a Kjetil Halvorsen> > Hi, all! > > I want to give an object to a function and use the NAME of this object > inside the function to build new objects based on this name. > > How do I get the name of an object if I don't pass a string containing > the name but the object itself? > > Christoph. > > -- > Christoph Lange > MPI fuer biologische Kybernetik |Phone: +49-7071-601-607| > Postfach 2169, D-72012 Tuebingen |FAX: +49-7071-601-616| > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help