[R] Return a variable name

soeren.vogel at eawag.ch soeren.vogel at eawag.ch
Fri Apr 16 11:26:14 CEST 2010


Hello,

how can I return the name of a variable, say "a$b", from a function?

fun <- function(x){
   return(substitute(x));
}
a  <- data.frame(b=1:10);
fun(a$b)

... returns a$b, but this is a type language, thus I can't use it as a  
character string, can I? How?

Thanks for help,

Sören



More information about the R-help mailing list