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:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/ 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gonzalo Rivero
Sent: Wednesday, 23 May 2007 8:14 PM
To: [email protected]
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

______________________________________________
[email protected] 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.

______________________________________________
[email protected] 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