[R] how to evaluate a dynamic variable?
Don MacQueen
macq at llnl.gov
Fri Apr 27 23:24:29 CEST 2007
Does
get(DV)
do what you want?
-Don
At 4:35 PM -0400 4/27/07, Bobby Prill wrote:
>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
>
>______________________________________________
>R-help at stat.math.ethz.ch 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.
--
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
More information about the R-help
mailing list