R/vec2tree.R

Defines functions vec2tree

Documented in vec2tree

vec2tree <-
function(vec){
	scale <- ceiling(log2(floor(length(vec)/2)+1))
	T <- list()
	T[[1]] <- vec[1]
	j = 1
	for(s in 1:scale)
	{
	T[[s+1]] <- vec[j+1:2^s]
	j <- j + 2^s
	}
	structure(list(T=T, max.s=scale), class = "binaryTree")	
}

Try the msBP package in your browser

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

msBP documentation built on Aug. 23, 2023, 1:06 a.m.