[R] Variable Names

Thomas Lumley thomas at biostat.washington.edu
Wed Feb 17 18:27:52 CET 1999


On Wed, 17 Feb 1999, Konstantinos Euripides Vorloou wrote:

> Dear R users,
> 
> That's probably a silly question even for a newbie but :
> 
> Is it possible to assign variable prices as variable names ?
> For instance, would something like the following work :
> 
> for (i in 1:4)
> {
>  error.i <- some_calculation
> }

It's possible but difficult and probably not what you want.

You can do something like
 assign(paste("error",i,sep="."),some.calculation)

but it's much easier to use a vector:

error<-numeric(4)
for (i in 1:4) {
	error[i]<-some.calculation
  }


Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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