[R] Name of data.frame as a text string?

Don MacQueen macq at llnl.gov
Thu Jul 2 21:21:49 CEST 2009


Use
   deparse(substitute(df))

Example from ?deparse:

     function(x, y) {
          plot(x, y, xlab=deparse(substitute(x)),
              ylab=deparse(substitute(y)))
      }

-Don

At 12:00 PM -0700 7/2/09, Mark Knecht wrote:
>I've passed a data.frame as an input into a function which does some
>plotting on a 4x4 matrix of certain parameters within in the
>data.frame. I'd like to add a small header on top of each plot with
>the name of the data.frame so that it's clear as I compare these 16
>things where each on came from.
>
>So far I haven't found the right way to get the name of the data.frame
>as a string which I can use in something like mtext. Is there one? If
>I put dummy text in, or take the time to pass in the name by hand,
>then I do get titles just as I'd like, but I'd far rather let the name
>of the data.frame speak for itself.
>
>Thanks,
>Mark
>
>______________________________________________
>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.


-- 
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062




More information about the R-help mailing list