Francisco,
I had exactly the same question a few days ago. Try the following:
z<-function(x)
{
xName <- deparse(substitute(x))
cat(xName)
cat("The parameter name was ",xName,"\n")
}
Let me know if this works.
n.b. the \n in the cat function is a signal to print the next piece of
data
on the next line.
John
John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
Baltimore VA Medical Center GRECC and
University of Maryland School of Medicine Claude Pepper OAIC
University of Maryland School of Medicine
Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
410-605-7119
- NOTE NEW EMAIL ADDRESS:
jsorkin@grecc.umaryland.edu
>>> "Francisco J. Zagmutt" <gerifalte28@hotmail.com>
7/18/2005 10:16:53
PM >>>
Dear all
How can I obtain the name of the argument passed in a function? Here
is a
simplistic example of what I would like to obtain:
myfunction= function(name) {
print(paste("The parameter name was",unknownFunction(name))
}
myfunction(myobject)
[1] "The parameter name was myobject"
Thanks
Francisco
______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
[[alternative HTML version deleted]]