[R] how to evaluate a dynamic variable?

Greg Snow Greg.Snow at intermountainmail.org
Fri Apr 27 23:10:55 CEST 2007


What are you trying to do with that?  Most times when someone asks this
question, they are trying to accomplish something that can be done
better a different way, so if you tell us what you are trying to
accomplish, we can suggest better approaches.

The short answer to your question is ?get.  

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
 
 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Bobby Prill
> Sent: Friday, April 27, 2007 2:35 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] how to evaluate a dynamic variable?
> 
> 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.
>



More information about the R-help mailing list