Skip to content

How to findout the name of a dataframe

3 messages · Frans Marcelissen, jim holtman, David Winsemius

#
Will this work for you:
+     # get the dataframe name
+     charName <- deparse(substitute(var))
+     # parse out data.frame
+     dataFrame <- sub("\\$.*", "", charName)
+     cat("input:", charName, "data.frame:", dataFrame, "\n")
+ }
input: mydata$V1 data.frame: mydata
On Sun, Feb 17, 2013 at 8:51 AM, Frans Marcelissen
<frans.marcelissen at digipsy.nl> wrote:

  
    
#
On Feb 17, 2013, at 5:51 AM, Frans Marcelissen wrote:

            
It will depend on the specifics. The usual way is with deparse(substitute(arg))
[1] "d"
[1] "d$a"

You do realize that mydata$v1 is identical (after evaluation, anyway)  to  mydata[,'v1'] , but not to mydata['v1'], don't you?
[1] "d[\"a\"]"
David Winsemius
Alameda, CA, USA