cdb_collapse {Rcompadre}R Documentation

Collapse a COM(P)ADRE database by averaging matrices over levels of one or more grouping variables

Description

Collapses a CompadreDB object by averaging matrices over levels of one or more grouping variables (e.g. SpeciesAuthor, MatrixPopulation).

For a given study and species, a COM(P)ADRE database may contain multiple matrices, reflecting different combinations of population, year, and/or treatment. Collapsing allows a user to obtain a single 'grand mean matrix' for each group of interest (e.g. MatrixPopulation), and therefore limit pseudoreplication.

All members of a group must have the same matrix dimension (consider adding MatrixDimension as a grouping variable). All members of a group should have the same ProjectionInterval and matrix stage class definitions (see cdb_id_stages). Note that Seasonal matrices should not be collapsed using this method (they should be matrix-multiplied rather than averaged).

Usage

cdb_collapse(cdb, columns)

Arguments

cdb

A CompadreDB object

columns

Vector of grouping variables to collapse over (corresponding to columns within cdb)

Details

Will give a warning if members of any group do not all share the same ProjectionInterval or stage class definitions, or if cdb contains any rows with a MatrixComposite value of "Seasonal".

Prior to collapsing, columns of class 'factor' will be coerced to 'character', and any list-column apart from mat will be removed.

Within a group, rows of a given column are collapsed as follows:

Value

A CompadreDB object

Author(s)

Patrick M. Barks <patrick.barks@gmail.com>

Owen R. Jones <jones@biology.sdu.dk>

See Also

cdb_id_stages

Other data checking: cdb_check_species(), cdb_compare(), cdb_flag(), mpm_methods

Examples

# filter out Seasonal matrices
CompSub <- subset(Compadre, MatrixComposite != "Seasonal")

# add column identifying unique stage class definitions
CompSub$id_stage <- cdb_id_stages(CompSub, "MatrixClassOrganized")

# collapse
CompCollapse <- cdb_collapse(CompSub, columns = c("id_stage"))


[Package Rcompadre version 1.3.0 Index]