group_by.treedata: Function for grouping an object of class 'treedata'

View source: R/treeplyr_functions.R

group_by.treedataR Documentation

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 class 'treedata'
group_by(.data, ..., add = FALSE)

## S3 method for class '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

Details

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

Value

An object of class grouped_treedata.

See Also

summarize

Examples

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))

uyedaj/treeplyr documentation built on March 9, 2023, 6:37 p.m.