[r] How to add elements to a list in R (loop)

I would like to add elements to a list in a loop (I don't know exactly how many)

Like this:

l <- list();
while(...)
   l <- new_element(...);

At the end, l[1] would be my first element, l[2] my second and so on.

Do you know how to proceed?

This question is related to r

The answer is


The following adds elements to a list in a loop.

l<-c()
i=1

while(i<100) {

    b<-i
    l<-c(l,b)
    i=i+1
}