Dear folks-- 

Suppose I have an expression that evaluates to a string, and that that
string, were it not a character vector, would be a symbol.  I would like a
function, call it doppel(), that will take that expression as an argument
and produce something that functions exactly like the symbol would have if I
typed it in the place of the function of the expression.  It should go as
far along the path to evaluation as the symbol would have, and then stop,
and be available for subsequent manipulation.  For example, if 

aa <- 3.1416 
bb  <- function(x) {x^2} 
r <- 2 
xx <- c("aa", "bb") 

out <- doppel(xx[1])*doppel(xx[2])(r) 

Then out should be 13.3664 

Or similarly, after 
doppel(paste("a",  "a",  sep=''))  <-  3 
aa 

typing aa should return 3. 

Is there such a function? Can there be? 

I thought as.symbol would do this, but it does not. 
> as.symbol (xx[1])*as.symbol (xx[2])(r) 
Error: attempt to apply non-function 




-----





--
View this message in context: 
http://r.789695.n4.nabble.com/Can-you-turn-a-string-into-a-working-symbol-tp4651634.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

Reply via email to