[R] Obtaining the name of an object XXXX

Rolf Turner rolf.turner at xtra.co.nz
Thu May 5 03:54:54 CEST 2011


On 05/05/11 11:16, Dan Abner wrote:
> Hello everyone,
>
> How does one write a function to return the name of an input object (that is
> assumed to be a data frame) as a character string? I tired using the get(),
> but this does not work as I had hoped. For example:
>
> myfn<-function(x){
>
> output<-data.frame(Attribute="Data Set Name",Value=as.character(get(x)))
>
> print(output)
>
> }

foo <- function(x) {
     deparse(substitute(x))
}

     cheers,

         Rolf Turner



More information about the R-help mailing list