[R] create a list of vectors

Arnau Mir Torres arnau at mnm.uib.es
Wed Mar 15 09:37:20 CET 2006


Hello.

I want to create a list of vectors but each component of the list has a 
different length.

For example:

Example=list()
Example=list(Example,c(1,2,3))
Example=list(Example,c(11,12,13,14,15))

If I want the first component of the Example list, I have to write:

Example[[1]][[2]]. R responses
1 2 3

The second component:
Example[[2]]:
11 12 13 14 15

If I iterate the previous example, Example=list(Example,c(...)) and I 
want the components, I have to write:
Example[[1]][[1]]...i times...[[1]][[2]]  (first component)
Example[[1]]...(i-1)times[[1]][[2]] (second component)
...

Can I make it in some other way?


Thanks,

Arnau.




More information about the R-help mailing list