PageRenderTime 24ms CodeModel.GetById 17ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/working/auteur/R/choose.one.R

http://github.com/eastman/auteur
R | 22 lines | 16 code | 2 blank | 4 comment | 3 complexity | 82cbddf71cc42ea9fc893d568d267446 MD5 | raw file
 1#general phylogenetic utility for selecting one element of a list of values, each of which can be associated with the edges of a phylogeny (phy$edge[,2])
 2#author: JM EASTMAN 2010
 3
 4choose.one <-
 5function(cur.delta, phy=NULL, internal.only=FALSE)
 6# updated 12.16.2010
 7{
 8	bb=cur.delta
 9	if(internal.only) {
10		while(1) {
11			s=sample(1:length(bb),1)
12#			print(bb[s])
13			names(bb)=phy$edge[,2]
14			if(as.numeric(names(bb[s]))>Ntip(phy)) break()
15		}
16	} else {
17		s=sample(1:length(bb),1)
18	}
19	bb[s]=1-bb[s]
20	bb
21}
22