[6555] in s-news-athena

home help back first fref pref prev next nref lref last post

How to get the names of arguments in functions?

daemon@ATHENA.MIT.EDU (Naoki Saito)
Thu Mar 2 16:59:42 1995

Date: Thu, 02 Mar 1995 16:03:20 -0500 (EST)
From: saito@ridgefield.sdr.slb.com (Naoki Saito)
To: s-news@utstat.toronto.edu
Cc: saito@ridgefield.sdr.slb.com

Hi!  I would like to manipulate the actual argument names inside the
function. For example, I would like to do the following type of things:

***Splus session.
> foo <- rnorm(100)
> tmp.func(foo)
"foo.tmp" is generated!

***tmp.func definition.
tmp.func <- function(x)
{
# I would like to get the actual name of the object x here.
# Suppose I got somehow, the name of the object as x.name as a charcter string.
#
 tmp <- eval(parse(text=paste(x.name, ".tmp<-x^2", sep="")))
 assign(paste(x.name,".tmp",sep=""), tmp, frame=0)
 cat(paste(x.name,".tmp is generated!\n",sep=""))
}

As a result of this operation, I would like to create foo.tmp in the
current Splus objects directory as a side effect.

I would appreciate your help!

Best wishes,
===============================================================================
            Naoki Saito                         Schlumberger-Doll Research
Email: saito@ridgefield.sdr.slb.com             Old Quarry Road
Voice: (203) 431-5209  Fax: (203) 438-3819      Ridgefield, CT 06877 USA
===============================================================================

home help back first fref pref prev next nref lref last post