[R] Variable Names

Jonathan Myles jonathan.myles at mrc-bsu.cam.ac.uk
Wed Feb 17 18:32:04 CET 1999



for(i in 1:4){
 eval(parse(text=paste("error.",i," <- i ",sep="")))
 }
> error.1
[1] 1
> error.2
[1] 2
> error.3
[1] 3
> error.4
[1] 4
> 

(but wouldn't a vector of length 4 be more convenient ....?)

Jonathan
---------------------
 Date: Wed, 17 Feb 1999 17:07:43 +0000
   From: Konstantinos Euripides Vorloou <K.E.Vorloou at durham.ac.uk>
   Organization: Dept. of Economics - University of Durham (UK)
   X-Accept-Language: en,el
   Content-Type: text/plain; charset=iso-8859-7
   Sender: owner-r-help at stat.math.ethz.ch
   Precedence: bulk

   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
   }

   so "error.i" variables would be created for i=1,2,3,4
   i.e.  error.1 error.2 error.3 etc. etc.


   Costas
   --
   ---------------------------------------------------------------------
   Konstantinos E. Vorloou           | Tel: +44 (0)191 374 1821
   Dept. of Economics & Finance      | Fax: +44 (0)191 374 7289
   University of Durham,             | email: K.E.Vorloou at durham.ac.uk
   23/26 Old Elvet,                  | or : vorlow at rocketmail.com
   Durham DH1 3HY,                   | ---------------------------------
   UK.                               | http://www.durham.ac.uk/~dec3kev
   http://www.durham.ac.uk/Economics | ICQ: 20595534
   ---------------------------------------------------------------------


-- 
Dr. Jonathan Myles         e-mail:jonathan.myles at mrc-bsu.cam.ac.uk
MRC Biostatistics Unit     Tel. 01223 330371
Institute of Public Health FAX  01223 330388
University Forvie Site
Robinson Way
CAMBRIDGE
CB2 2SR                   
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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