Dear Duncan On Wed, 04 Aug 2010 08:33:49 -0400 Duncan Murdoch <murdoch.dun...@gmail.com> wrote: > As other have pointed out, in a function you can use substitute(arg) > to retrieve the expression passed as arg, and > deparse(substitute(arg)) to turn it into a string that's suitable for > using as a label. But that's not the name of the object. The name > of the object in that case is "arg". > Thank you for the explanation. I was indeed trying to retrieve the expression passed as an argument in a function, to use it as a label. Sofar the best I can manage is this: my.fun <- function(x) { print(deparse(substitute(x))) print(paste(substitute(x)[3])) }
> my.fun(mtcars$cyl) [1] "mtcars$cyl" [1] "cyl" Thanks all for their suggestions Liviu ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.