Dear Phylofolks,

Suppose I have a phylo object phy and the states at all nodes (internal and
external). Would the following function give me the number of state changes?

get.changes <- function(tree, states){
  sum(apply(phy$edge, 1, function(x)  states[x[1]]!=states[x[2]]))
}

If not, what would?

Thanks in advance,

Luiz
-- 
Luiz Max Fagundes de Carvalho
PhD student, Institute of Evolutionary Biology,  School of Biological
Sciences,
Ashworth Laboratories, Ash 2, office 123
University of Edinburgh, United Kingdom.
http://br.linkedin.com/pub/luiz-max-carvalho/49/687/283

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

Reply via email to