Hi, Suppose I have a function: myfunc <- function(x, y) { ... } And within the function I want to print out the name of the x, y vectors. For example, if I do:> myfunc(foo, goo)[1] "foo" "goo" It shall return "foo", "goo" (with or without quotes is fine), where foo and goo are two vectors with numbers. I know this sounds strange, but I'd like to use it for debugging purposes. Cheers, Kevin ------------------------------------------------------------------------------ Ko-Kang Kevin Wang Postgraduate PGDipSci Student Department of Statistics University of Auckland New Zealand Homepage: http://www.stat.auckland.ac.nz/~kwan022 E-mail: kwan022 at stat.auckland.ac.nz -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Mon, May 06, 2002 at 09:18:19PM +1200, Ko-Kang Kevin Wang wrote:> Hi, > > Suppose I have a function: > myfunc <- function(x, y) { > ... > } > > And within the function I want to print out the name of the x, y > vectors. For example, if I do: > > myfunc(foo, goo) > [1] "foo" "goo" >Something like myfunc <- function(x,y,...) { c(deparse(substitute(x)),deparse(substitute(y))) } myfunc("foo","goo") [1] "\"foo\"" "\"goo\"" zz <- "foo" zy <- "goo" myfunc(zz,zy) [1] "zz" "zy" Cheers Jason -- Indigo Industrial Controls Ltd. 64-21-343-545 jasont at indigoindustrial.co.nz -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> > Suppose I have a function: > myfunc <- function(x, y) { > ... > } > > And within the function I want to print out the name of the x, y > vectors. For example, if I do: > > myfunc(foo, goo) > [1] "foo" "goo" > > It shall return "foo", "goo" (with or without quotes is fine), where foo > and goo are two vectors with numbers. >This should be a good place to start> myfunc <- function(x,y) {+ call <- match.call() + as.character(call)[-1] + }> foo <- exp(1) > myfunc(foo,"goo")[1] "foo" "goo">Sundar -- Sundar Dorai-Raj, Ph.D. Statistical Methods Engineer PDF Solutions, Inc. Richardson TX (972) 889-3085 x216 (214) 392-7619 cell sundard at pdf.com -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Ko-Kang Kevin Wang wrote:> > Hi, > > Suppose I have a function: > myfunc <- function(x, y) { > ... > } > > And within the function I want to print out the name of the x, y > vectors. For example, if I do: > > myfunc(foo, goo) > [1] "foo" "goo" > > It shall return "foo", "goo" (with or without quotes is fine), where foo > and goo are two vectors with numbers.Try substitute(). Uwe> I know this sounds strange, but I'd like to use it for debugging purposes. > > Cheers, > > Kevin > > ------------------------------------------------------------------------------ > Ko-Kang Kevin Wang > Postgraduate PGDipSci Student > Department of Statistics > University of Auckland > New Zealand > > Homepage: http://www.stat.auckland.ac.nz/~kwan022 > > E-mail: kwan022 at stat.auckland.ac.nz > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._