[R] how to evaluate a dynamic variable?

Bobby Prill rprill at jhu.edu
Fri Apr 27 22:35:08 CEST 2007


Please help me evaluate a "dynamic variable" as show in the code  
snippet below.

# regular variable
a = c(1,2,3,4)

# dynamic variable set at runtime
DV = "a"

eval(DV)
--> a

eval(eval(DV))
--> a

# what I want
something_goes_here(DV)
-->  1,2,3,4

Can someone teach me how to do this?  Thanks very much.

- Bobby



More information about the R-help mailing list