[R] evaluating the contents of a string

Keith Richards-Dinger dinger at mchinji.wr.usgs.gov
Sat Sep 29 00:50:34 CEST 2001


On Fri, 28 Sep 2001, David A Richmond wrote:

> suppose I do: 
> 	b <- matrix(1:9,3,3)
> 	bname <- "b"
>
> 	dim(bname)
> returns
> 	NULL
> 
> is there a function to pass bname to such that dim returns the dimensions
> of b?
> 
> like 
> 	dim(somefunc(bname))
> returns
> 	[1] 3 3 

> 
> does 'somefunc' exist?

R> dim(eval(parse(text=bname)))
[1] 3 3


---------------------------------------------------------------------------
Keith Richards-Dinger
U.S. Geological Survey, MS-977          Office 1-650-329-5519
345 Middlefield Road                    Fax    1-650-329-5163
Menlo Park, CA  USA  94025              e-mail dinger at usgs.gov
---------------------------------------------------------------------------



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list