I don't know if this has already been answered, but read.nexus.data in ape automatically creates a list character vectors. To get the number of states in each character you can do:

N<-apply(data.frame(X),1,function(x) length(unique(x)))

if your data is an object of class "DNAbin" then the following highly similar code does the same thing:

N<-apply(as.matrix(X),2,function(x) length(unique(x)))

Let us know if you found another solution or if this does not work.

All the best, Liam

Liam J. Revell, Assistant Professor of Biology
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/
email: liam.rev...@umb.edu
blog: http://blog.phytools.org

On 3/6/2015 6:19 AM, Paolo Piras wrote:
Hi folks,
I have a nexus data matrix with n taxa and m discrete characters (including 
some polymorphisms); I would like to  know which characters are binary and 
which ones are multistate.
Maybe some manual coding will be sufficient but just in case...there is a 
function, in your knowledge, able to do that?

Thankyou in advance

Paolo Piras


_______________________________________________
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