R/ancestors.R

Defines functions ancestors

Documented in ancestors

ancestors <-
function(x, ID, sources) {
  transchain <- x
  cur <- x
  while(1) {
    cur <- sources[which(ID==cur)]
    transchain <- c(transchain, cur)
    if (cur == 0) {
      break
    }
  }
  return(as.numeric(transchain))
}

Try the seedy package in your browser

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

seedy documentation built on May 29, 2017, 10:58 a.m.