[R] How to recursively build a binary tree with R script?
Duncan Murdoch
murdoch at stats.uwo.ca
Wed Jun 24 20:52:30 CEST 2009
On 6/24/2009 2:02 PM, Mike Beddo wrote:
> Greetings!
>
> Can someone provide a simple script for a R function that recursively builds a binary tree. I am most familiar with C and pass by reference, but I think R is like Fortran and pass by value.
Here's a tree with a random depth:
makeTree <- function() {
if (runif(1) < 0.4) list(makeTree(), makeTree())
else "leaf"
}
Duncan Murdoch
More information about the R-help
mailing list