Learn R Programming

treeplyr (version 0.1.7)

group_by_.treedata: Function for grouping an object of class treedata

Description

This function can be used to group a treedata object by some factor.

Usage

# S3 method for treedata
group_by_(.data, ..., add = FALSE)

# S3 method for grouped_treedata ungroup(x, ...)

Arguments

.data

An object of class treedata

...

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 treedata

Value

An object of class grouped_treedata.

Details

Groups the data frame and phylogeny by one of the factors in the data table.

See Also

summarize

Examples

Run this code
# NOT RUN {
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))
# }

Run the code above in your browser using DataLab