Monday, April 23, 2012

Common error in make.simmap

A user today reported encountering the following error while using the phytools function make.simmap:

> mtree<-make.simmap(tree,y)
Error in if (names(map)[length(map)] == node.states[j, 2]) accept = TRUE :
  missing value where TRUE/FALSE needed
In addition: Warning message:
In sqrt(diag(solve(h))) : NaNs produced


It turns out that this is just due to the fact that the data y is a data frame, with species names in rows, rather than a vector with names(...) equal to the species names. Perhaps in the future I will modify make.simmap to rectify this problem, but for no this can be circumvented as follows:
> z<-y; names(z)<-rownames(y)
> mtree<-make.simmap(tree,z)


I figured that this was probably a sufficiently common problem for users of make.simmap to repeat on the blog.

No comments:

Post a Comment