Skip to content
Back to formatted view

Raw Message

Message-ID: <61D3C9CA-2D8E-4DE1-AE54-2486A346E6B6@auckland.ac.nz>
Date: 2010-01-27T19:06:25Z
From: Rolf Turner
Subject: Executing a R-string
In-Reply-To: <F2C90BED-A61B-49B5-B284-044118E0782A@mac.com>

On 28/01/2010, at 2:59 AM, Joe Trubisz wrote:

> Hello...
>
> In other languages (e.g. php, perl), you have the ability to create a
> valid string and execute the string to get the result. For example (in
> pseudo-R):
>
> S<-"which(m==4)"
> R<-exec(S)
>
> I know this does not work, but was wondering if there was an
> equivalent mechanism that I cannot find in the docs anywhere to make
> it work.

 > set.seed(42)
 > m <- sample(0:9,42,TRUE)
 > S <- "which(m==4)"
 > eval(parse(text=S))
[1] 11 15 19 29 42

	cheers,

		Rolf Turner


######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}