[R] loop in list

Greg Snow 538280 at gmail.com
Sun Jul 1 00:02:17 CEST 2012


Instead of a loop you can use the replicate or lapply functions which
will create lists for you.

otherwise you can start with an empty list (mylist <- list() )

then add to the list in each iteration of the loop:

for(i in 1:10) {
    mylist[[i]] <- myfunction(i)
}



On Sat, Jun 30, 2012 at 1:34 PM, solafah bh <solafahbh at yahoo.com> wrote:
> Hello
> I have a loop to sample 20 samples and I want to put them in one list, how I can make this??
>
> Regards
> Sulafah
>         [[alternative HTML version deleted]]
>
>
> ______________________________________________
> 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.
>



-- 
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com



More information about the R-help mailing list