[R] Combined variable names

Kjetil Brinchmann Halvorsen kjetil at acelerate.com
Wed Dec 1 14:49:17 CET 2004

Richard A. O'Keefe wrote:

>Tobias Muhlhofer <t.muhlhofer at lse.ac.uk> wrote:
>	I am trying to define a large number of variables through a loop
>	construct.
>He wants to do
>	for (i in 1:100) {
>	    assign(paste("v", i, sep=""), ....something or other...)
>	}
>This is, of course, a FAQ.  It's such a FAQ that I must have seen it
>once a day for the last several days.
>What I want to know is *WHY* people are doing this?
Bad habits from less expressive languages?


>What, precisely, does it buy you to have variables called v1...v100
>rather than variables called v[[1]]...v[[100]]?
>Apart from persistent inconvenience, that is?
>What, really, is wrong with
>    v <- lapply(1:100, function (i) ....something or other...)
>R-help at stat.math.ethz.ch mailing list
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Kjetil Halvorsen.

Peace is the most effective weapon of mass construction.
               --  Mahdi Elmandjra

More information about the R-help mailing list