Message-ID: <CA+8X3fWrhYFtYrckbx4Q_9bVfTFt5jNRWsV8y6=O=hPqAgMT6Q@mail.gmail.com>
Date: 2015-08-08T22:33:54Z
From: Jim Lemon
Subject: Recursive looping of a list in R
In-Reply-To: <1439057640651-4710898.post@n4.nabble.com>
Hi Evans,
I'm not sure whether this is what you want, but look at the code in
the listBuilder and listCrawler functions in the crank package.
Jim
On Sun, Aug 9, 2015 at 4:14 AM, Evans <evansochiaga at aims.ac.za> wrote:
> I am trying to creat a list from a loop such that once you loop the value
> obtained is appended onto the list, then you loop through that value to give
> the next elemet of the list and the system continues recusively. To be clear
> I am creating a list to contain elements of the following tree
> probabilities;
> <http://r.789695.n4.nabble.com/file/n4710898/help.png> . The elements of the
> diagram should be presented in a list such that each level of the tree
> represents elements in the list (only the coefficients are of interest). I
> have this code to start with
>
> j <- 0
>
> while(j >= 0){
>
> j <- j+1
>
> occlist <- list(1)
>
> for(i in occlist[[j]]){
>
> occ_cell <- seq(i, i+1, by = 1)
>
> occllist <- list(occ_cell)
>
> occunlist <- as.vector(unlist(occllist, recursive = TRUE))
>
> occlist[[j]] <- occunlist
>
> print(occlist)
>
> }
> }
>
> Any assistance will be highly appreciated. Thanks.
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Recursive-looping-of-a-list-in-R-tp4710898.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.