Hello,

I don't know if it is the most efficient way to do but my solution is:

x <- vector("list", 10) #creates a list with a length = 10

then in my loop (where i is iterated) :

x[[i]] <- my.vector

I hope this could help you

François Michonneau




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.

        [[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to