[R] re ferring to a group of vectors without explicit enumeration
shalu
shahlar at hotmail.com
Sun Sep 7 17:46:38 CEST 2008
Thanks very much. This is what I implemented. I found a similar example
elsewhere too.
It works fine now.
jholtman wrote:
>
> I would suggest that you use a list to store the values since it is
> easier to create and reference:
>
>> output <- list()
>> for (i in 1:10) output[[i]] <- seq(i)
>>
>> output
> [[1]]
> [1] 1
>
> [[2]]
> [1] 1 2
>
> [[3]]
> [1] 1 2 3
>
> [[4]]
> [1] 1 2 3 4
>
> [[5]]
> [1] 1 2 3 4 5
>
> [[6]]
> [1] 1 2 3 4 5 6
>
> [[7]]
> [1] 1 2 3 4 5 6 7
>
> [[8]]
> [1] 1 2 3 4 5 6 7 8
>
> [[9]]
> [1] 1 2 3 4 5 6 7 8 9
>
> [[10]]
> [1] 1 2 3 4 5 6 7 8 9 10
>
>>
>
>
> On Sat, Sep 6, 2008 at 5:33 PM, shalu <shahlar at hotmail.com> wrote:
>>
>> 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.
>> --
>> View this message in context:
>> http://www.nabble.com/referring-to-a-group-of-vectors-without-explicit-enumeration-tp19351518p19351518.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
--
View this message in context: http://www.nabble.com/referring-to-a-group-of-vectors-without-explicit-enumeration-tp19351518p19359352.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list