s-news
[Top] [All Lists]

[S] deparse+substitute

To: s-news@wubios.wustl.edu
Subject: [S] deparse+substitute
From: "Paul Quataert" <Paul.Quataert@ihe.be>
Date: Thu, 23 Apr 1998 10:31:57 MET-1METDST
Organization: I.H.E.-Epidemiology,BRUSSELS,BELGIUM
Sender: owner-s-news@wubios.wustl.edu
I want to use the deparse(substitute()) combination
to create labels, e.g.
   tstS <- function(xv) deparse(substitute(xv))
Then I get for 
   tstS(letters)
   [1] "letters"

Everything is OK for now. However this trick does not 
work anymore when I use tstS as a subroutine in another 
procedure, e.g.
   tstM <- function(...) tstS(...)
Then I get
   tstM(xv=letters)
   [1] "..1"
which is the name of the variable in tstM, and not the 
name of the original variable.

Does there exist a DIRECT way to fix this problem ?

NOTE:
Surely there exist indirect solutions, e.g.
   tstS <- function(xv,xlab=deparse(substitute(xv))) xlab
   tstM <- function(xv,...) tstS(xv,deparse(substitute(xv)))
   tstM(xv=letters)
   "letters"

This works fine, but then I need to define the variable 
xv in the main procedure tstM, something I prefer not 
to do for my application (and anyhow tstM will not work
anymore when I use this in another procedure).

Thanks for any help.

Paul Quataert
Scientific Instititute of Public Health, Louis Pasteur
(formerly I.H.E. Institute of Hygiene and Epidemiology
Department of Epidemioly
J. Wytsmanstraat 14
1050            BRUSSEL

tel. +32-2-642 54 02  fax. +32-2-642 54 10
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

<Prev in Thread] Current Thread [Next in Thread>