[R] re ferring to a group of vectors without explicit enumeration

Ben Bolker bolker at ufl.edu
Sun Sep 7 00:07:47 CEST 2008

shalu <shahlar <at> hotmail.com> writes:

> I am trying to define 25 vectors of varying lengths, say y1 to y25 in a loop,
> and then store the results of some computations in them. My problem is about
> using some sort of concatenation for names. For example, instead of
> initializing each of y1 through y25, I would like to do it in a loop.
> Similar to cat and paste for texts, is there anyway of using y"i" for the
> vector name where i ranges from 1 to 25, so ultimately it refers to the
> vector y1,..,y25?
> Varying lengths is not a problem. To start with each has only length 1 and
> then I will be adding to each vector based on some results.

  I think this is essentially


[URL broken in order to make Gmane happy, reassemble it 
in your browser]

  the short answer: assign(), but it would work better
to use a list instead.

  Ben Bolker

More information about the R-help mailing list