View source: R/treeplyr_functions.R
group_by.treedata | R Documentation |
treedata
This function can be used to group a treedata object by some factor.
## S3 method for class 'treedata'
group_by(.data, ..., add = FALSE)
## S3 method for class 'grouped_treedata'
ungroup(x, ...)
.data |
An object of class |
... |
The name of the grouping factor. |
add |
By default, when add = FALSE, group_by will override existing groups. To instead add to the existing groups, use add = TRUE |
x |
An object of class |
Groups the data frame and phylogeny by one of the factors in the data table.
An object of class grouped_treedata
.
summarize
data(anolis)
td <- make.treedata(anolis$phy, anolis$dat)
tdGrouped <- group_by(td, ecomorph)
summarize(tdGrouped, ntips = length(phy$tip.label),
totalBL = sum(phy$edge.length), meanSVL = mean(SVL), sdSVL = sd(SVL))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.