Re: [R-sig-phylo] identify duplicate topologies and add corresponding values
Here is a solution to identify the unique topologies in your dataset and then average some quantity over them. Let us know if it works: http://blog.phytools.org/2016/05/identifying-unique-tree-topologies-in.html All the best, Liam Liam J. Revell, Associate Professor of Biology University of Massachusetts Boston web: http://faculty.umb.edu/liam.revell/ email: [email protected] blog: http://blog.phytools.org On 5/30/2016 1:52 PM, John Denton wrote: Hi Liam, Thanks for this. Yes, it looked back at the script and it is actually a data frame. I realized my question wasn't clear. Th second column has the actual trees as each entry (not just A, B, C, etc), which I suppose makes it more complicated--isn't an RF.dist/multiRF call needed? Best, ~John John S. S. Denton, Ph.D. Department of Vertebrate Paleontology American Museum of Natural History www.johnssdenton.com From: Liam J. Revell [[email protected]] Sent: Monday, May 30, 2016 12:53 PM To: John Denton; [email protected] Subject: Re: [R-sig-phylo] identify duplicate topologies and add corresponding values 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 aggregate(obj$number,by=list(obj$tree),sum) - Liam Liam J. Revell, Associate Professor of Biology University of Massachusetts Boston web: http://faculty.umb.edu/liam.revell/ email: [email protected] blog: http://blog.phytools.org On 5/30/2016 12:13 PM, John Denton wrote: 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 - [email protected] https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/[email protected]/ ___ R-sig-phylo mailing list - [email protected] https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/[email protected]/
Re: [R-sig-phylo] identify duplicate topologies and add corresponding values
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 - [email protected] https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/[email protected]/
Re: [R-sig-phylo] identify duplicate topologies and add corresponding values
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
aggregate(obj$number,by=list(obj$tree),sum)
- Liam
Liam J. Revell, Associate Professor of Biology
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/
email: [email protected]
blog: http://blog.phytools.org
On 5/30/2016 12:13 PM, John Denton wrote:
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 - [email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/[email protected]/
___
R-sig-phylo mailing list - [email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/[email protected]/
[R-sig-phylo] identify duplicate topologies and add corresponding values
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 - [email protected] https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/[email protected]/
