string - Treat a Character as a variable -
suppose have following code
a<-c(1,2,3) b<-'a'
now treat string in 'b' variable 'a' when input function or operation. imagine "treat.as.variable()" real function this:
treat.as.variable(b)+c(1,2,4) [1] 2 4 7
is there function this, predefined? or way in general?
use get
function
> get(b) + c(1,2,4) [1] 2 4 7
Comments
Post a Comment