sum_tips: Sum up values assigned to tips of a tree down its nodes. It...

Description Usage Arguments Details Examples

Description

Sum up values assigned to tips of a tree down its nodes. It is used to get total fundings for each node, but can be used to sum up any tip value up to all nodes

Usage

1
sum_tips(tree, values)

Arguments

tree

A phylo object

values

A numeric vector named with the tip labels of the tree. Names must match tip labels from tree.

Details

For now you must use tip labels to name the values vector. We can later just take values in the order of tips, in case users do not want to name their values vector.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# generate a random tree:
library(ape)
t1 <- rcoal(10)
# generate some fake richness data
r1 <- c(rep(1,5), 400, 20, 30, 5, 200)
names(r1) <- t1$tip.label
# get the node richness values
x <- sum_tips(tree = t1, values = r1)
# plot them:
plot(t1, label.offset = 0.1)
tiplabels(x[1:Ntip(t1)], cex = 0.5)
nodelabels(x[-c(1:Ntip(t1))], cex = 0.5)

LunaSare/phunding documentation built on May 25, 2019, 1:36 p.m.