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 column and a numeric value associated with each tree in the other column. I would like to go through the list to identify any duplicated topologies, and for each set of duplicates sum the corresponding numeric values and prune away the duplicate trees.
For example, 1.0 A 1.5 A 0.2 B 0.8. C 1.0. A 3.2. B Would become 3.5. A 3.4. B 0.8. C Any help would be great! Thanks, ~John
_______________________________________________ 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/