Hi Nia,
Many ways to do something like this, for example:
N<-6
sapply(1:N,function(x) return(sample(1:10,x,TRUE)))
I'll let you work out how to generalize this.
Jim
On Sun, Jun 14, 2015 at 3:06 PM, Bert Gunter <bgunter.4567 at gmail.com>
wrote:> Is this homework? Homework is deprecated here.
>
> ?lapply
>
> is one of many possible approaches. If this is not homework, showing your
> unsuccessful code would likely lead to a better learning experience for
you.
>
> Cheers,
> Bert
>
> Bert Gunter
>
> "Data is not information. Information is not knowledge. And knowledge
is
> certainly not wisdom."
> -- Clifford Stoll
>
> On Sat, Jun 13, 2015 at 8:04 AM, Nia Gupta via R-help <r-help at
r-project.org>
> wrote:
>
>> Hello,
>>
>> I am trying to create a list where each name would have an increasing
>> vector length. For example, I am trying to obtain something that looks
like
>> this:
>>
>> [[1]][1] 2
>> [[2]]
>> [1] 2 4
>>
>> [[3]]
>> [1] 1 2 3
>> .....
>> The numbers generated would just be any random numbers. My thought was
to
>> use a for-loop and the sequence function but that doesn't seem to
be
>> working. Any help on this would be greatly appreciated.
>>
>> Thank you,
>>
>> Nia
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.