R/branches.per.tip.R

Defines functions branches.per.tip

Documented in branches.per.tip

branches.per.tip <- function(phy){
	tips <- length(phy$tip.label)
	root <- tips + 1
	mat <- phy$edge
	li <- list()
	for(i in 1:tips){
		edge <- which(mat[,2] == i)
		res <- mat[edge,1]
		li[[i]] <- edge
		while(res != root){
			edge <- which(mat[,2] == res)
			res <- mat[edge,1]
			li[[i]] <- c(li[[i]], edge)
		}
	}
	li
}

Try the spiderDev package in your browser

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

spiderDev documentation built on May 2, 2019, 5:23 p.m.