[R] geeting name of an object to which a variable refers?

Liaw, Andy andy_liaw at merck.com
Fri May 11 21:41:40 CEST 2007


 Something like this?

R> f <- function(x) deparse(substitute(x))
R> a <- 1:3
R> f(a)
[1] "a"

Andy

From: new ruser
> 
> #Sorry for the convoluted subject line.
> 
> #I have:
> 
> a=c(1,2,3)
> x=a #example of user supplied input
> 
> 
> #Is there any function that will tell me the "name" of the 
> object x refers to, referring only to x itself? 
> #i.e. the "answer" I want is "a"
> 
> #I want: 
> #fun(x) == 'a'
> 
> #(I don't think this is possible, but figured I'd ask.)
> 
> 
> 
>        
> ---------------------------------
> Got a little couch potato? 
> Check out fun summer activities for kids.
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.
> 
> 
> 


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments,...{{dropped}}



More information about the R-help mailing list