From spencer.graves at prodsyse.com  Sun May  7 21:56:34 2017
From: spencer.graves at prodsyse.com (Spencer Graves)
Date: Sun, 7 May 2017 14:56:34 -0500
Subject: [Rd] deparse(substitute(x)) fails in implied call to an S3 print
	method
Message-ID: <d57cd70d-50e6-5fae-e9a2-0566b367c9c8@prodsyse.com>

In an implied call to an S3 print method, deparse(substitute(x)) returns 
"x", regardless of the name of object in .GlobalEnv, as indicated in the 
following:


 > Xnamed <- 1
 > class(Xnamed) <- 'name.x'
 > print.name.x <- function(x, ...){
+   namex <- deparse(substitute(x))
+   cat('How can I get the name of x in .GlobalEnv?\n',
+       'deparse(substitute(x)) gives only ', namex, '\n')
+ }
 > Xnamed
How can I get the name of x in .GlobalEnv?
  deparse(substitute(x)) gives only  x


       My real application is print.findFn{sos}, which displays in a web 
browser.  If the results of multiple searches are "printed", the name of 
the object in .GlobalEnv could help the user keep track of what was done.

       Thanks,
       Spencer Graves


 > sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.4

Matrix products: default
BLAS: 
/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: 
/Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods base

loaded via a namespace (and not attached):
[1] compiler_3.4.0 tools_3.4.0



[Rd] deparse(substitute(x)) fails in implied call to an S3 print method
Spencer Graves