Skip to content
Back to formatted view

Raw Message

Message-ID: <418A3FA0.4090007@pdf.com>
Date: 2004-11-04T14:41:36Z
From: Sundar Dorai-Raj
Subject: Conversion of strings to expressions
In-Reply-To: <41A7214E@webmail2.ofir.dk>

Alexander Sokol wrote:

> Hello,
> 
> I'm not sure how to state my question in a technically accurate manner, so 
> I'll use a short example to clarify my problem:
> 
> Say I have a vector,
> 
> vec<-c(1,2,3,2)
> 
> I would like to be able to "reference" the vector by using the string 
> containing the name of the vector - that is, I would like to know of some 
> function which is able to convert the string "vec" into the vector vec itself. 
> The purpose of this is to be able to do something like
> 
> 
>>somefunc("vec")==2
> 
> [1] FALSE TRUE FALSE TRUE
> 
> I hope it is clear from this what the problem is. It seems to me that the 
> function desired is akin to a sort of "inverse" to the quote() function, but I 
> have been unable to find such a function.
> 
> I am using R 1.9.1 on Windows 2000 SP4. Does anyone have a suggestion of how 
> to solve the problem?
> 
> Thanks,
>  Alexander
> 

I think you want ?get. This is FAQ 7.21.

--sundar