[R] retrieve name of an object?

jim holtman jholtman at gmail.com
Wed Aug 4 13:53:35 CEST 2010


I am not sure what you mean by a "hack"?  Can you elaborate further,
give details on the problem you are trying to solve.

Does this work as a "lesser hack":

> tail(as.character(quote(mtcars$cyl)),1)
[1] "cyl"
> tail(as.character(quote(cyl)),1)
[1] "cyl"
>


On Wed, Aug 4, 2010 at 7:47 AM, Liviu Andronic <landronimirc at gmail.com> wrote:
> Dear all
> Is there an easier way to retrieve the name of an object? For example,
>> tmp <- 1:10
>> as.character(quote(tmp))
> [1] "tmp"
>> as.character(quote(mtcars$cyl))
> [1] "$"      "mtcars" "cyl"
>> as.character(quote(mtcars$cyl))[3]
> [1] "cyl"
>
> The last call more than anything seems a hack. Is there a better way?
>
> Thank you
> Liviu
>
> ______________________________________________
> R-help at 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list