R/descendants.R

Defines functions descendants

descendants <- function(m,k){
  ## the done object indicates what rows of m were used
  done <- k
  if (m[k,1] < 0)
    left <- -m[k,1]
  else {
    junk <- descendants(m, m[k,1])
    left <- junk[[1]]
    done <- c(done, junk[[2]])
  }
  if (m[k,2] < 0)
    right <- -m[k,2]
  else {
    junk <- descendants(m, m[k,2])
    right <- junk[[1]]
    done <- c(done, junk[[2]])
  } 
  return(list(c(left, right), done))
}

Try the pamr package in your browser

Any scripts or data that you put into this service are public.

pamr documentation built on July 1, 2024, 9:06 a.m.