Message-ID: <t5xaa464nwa.fsf@rgc.damtp.cam.ac.uk>
Date: 2012-02-25T21:13:41Z
From: Stephen Eglen
Subject: Finding name of variable supplied as function argument
> I could of course do this the tedious way by simply entering
> the name-strings "G1", "G2" as arguments as well as the variable
> names G1, G2, in a call like
>
> meds3x3(G1,G2,"G1","G2")
>
> But I'd like to simply be able to pick up, within the function,
> the names of the variables that were used as arguments in the
> function call.
does the following help Ted?
test <- function(x) {
actual <- deparse(substitute(x))
paste('argument passed was called', actual)
}
test(happy)
test(apple)