[R] referencing values of strings

Marc Schwartz MSchwartz at MedAnalytics.com
Wed Nov 17 18:30:42 CET 2004


On Wed, 2004-11-17 at 10:48 -0500, Apoian, Zack wrote:
> Say you have a vector named x and a function which returns the character
> string "x" .  How would I take "x" as an input and return the vector x?


If I am understanding you correctly:

x <- 1:10

> x
 [1]  1  2  3  4  5  6  7  8  9 10

x.char <- "x"

> get(x.char)
 [1]  1  2  3  4  5  6  7  8  9 10


See ?get for more information.

HTH,

Marc Schwartz




More information about the R-help mailing list