Re: [R-sig-phylo] identify duplicate topologies and add corresponding values

2016-05-30 Thread Emmanuel Paradis
Hi John, Something like this does what you are looking for: z <- tapply(X[, 1], X[, 2], sum) To have it in a matrix-like layout (similar to X): data.frame(z, names(z)) Best, Emmanuel Le 30/05/2016 18:13, John Denton a écrit : Hi all, I have a two-column matrix, containing trees in one

Re: [R-sig-phylo] identify duplicate topologies and add corresponding values

2016-05-30 Thread Liam J. Revell
Hi John. This would have to be a data frame (not a matrix) as you could not have different data types in your matrix. Try the function aggregate, e.g.: obj<-data.frame(number=c(1,1.5,0.2,0.8,1.0,3.2), tree=factor(c("A","A","B","C","A","B"))) obj ## data frame