[R] name of object in quotes

Bill.Venables at csiro.au Bill.Venables at csiro.au
Wed May 23 14:16:23 CEST 2007


This is a long-standing idiom:

> foo <- function(xvar) deparse(substitute(xvar))
> foo(x1)
[1] "x1"

 


Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred):   +61 7 3826 7251
Fax (if absolutely necessary):      +61 7 3826 7304
Mobile:                                   (I don't have one!)
Home Phone:                            +61 7 3286 7700
mailto:Bill.Venables at csiro.au
http://www.cmis.csiro.au/bill.venables/ 

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Gonzalo Rivero
Sent: Wednesday, 23 May 2007 8:14 PM
To: R-help at stat.math.ethz.ch
Subject: [R] name of object in quotes

I am writing a function in which, at some point, I to recuperate the
name of a previous object in quotes. I am currently using the function
Cs() from the Hmisc library but the result is:

foo <- function(xvar) {
    variable <- Cs(xvar)
    return(variable)
}

foo(x1)
> "xvar"

when I would expected to obtain "x1".

Any suggestion?

Thanks


-- 
*Gonzalo Rivero*
Ph.D. candidate

Centro de Estudios Avanzados en Ciencias Sociales
Juan March Institute
Castelló 77, 2nd floor
28006, Madrid

______________________________________________
R-help at stat.math.ethz.ch 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.



More information about the R-help mailing list