AggregateCommunities {cheddar}R Documentation

Aggregate communities


Functions that aggregate communities in a collection.


                     aggregate = names(collection), 
                     title = NULL)

AggregateCommunitiesBy(collection,, ...)



an object of class CommunityCollection.


the names of the communities to aggregate.

the name of a column by which to compute weighted mean of numeric values.


the title of the new Community.

the name of a community property, either first-class or computed, over which to aggregate.


values passed to AggregateCommunities.


AggregateCommunities combines communities given in aggregate in to a single new Community.

Nodes that appear in one or more of the communities in aggregate are combined into a single node in the returned community. The way in which numeric node properties are aggregated is governed by the parameter. If is NULL or is not the name of a node property, the arithmetic mean is computed for each numeric node property. If is the name of a node property, that property is used to compute weighted means of the other numeric node properties; the arithmetic mean of is computed. This scheme means that if a community contains both N and M, aggregation using'N' results in the arithmetic mean of N and the N-weighted mean of M for each node. Node properties that are characters or logicals are aggregated by joining unique values with a ‘,’. Empty character strings are ignored. Species that are not present in some communities in the collection are assumed to have a value of 0 for all numeric node properties, an empty string ('') for all character node properties and a value of NA for all logical node properties.

The returned community contains the union of trophic links for each node. Community properties are aggregated by computing the arithmetic mean of numeric values and joining unique character and logical values with a ‘,’.

See the ‘Aggregating communities’ section of the ‘Collections’ vignette for a more detailed explanation and examples of how properties are aggregated.

AggregateCommunitiesBy aggregates by a property of the communities, either first-class or computed. If there is more than one unique value of the property across the contained communities, a new CommunityCollection object is returned. If there is just one unique value, a single Community is returned.


A new object that is either of class Community or CommunityCollection.


Lawrence Hudson

See Also

CommunityCollection, CollectionCPS



# An aggregate of 3 communities
AggregateCommunities(pHWebs, c('Old Lodge', 'Afon Hafren', 'Broadstone'))

# The Duddon Pike Beck and Mosedal Beck communities share the same 
# latitude and have pH values of 6.1 and 5.9 respectively.
CollectionCPS(pHWebs[c('Duddon Pike Beck', 'Mosedal Beck')])

# Aggregating by the 'lat' property therefore results in a new collection 
# of nine communities.
CollectionCPS(AggregateCommunitiesBy(pHWebs, 'lat'))

# Would produce an error
## Not run: AggregateCommunities(pHWebs, c('not a community', 'Afon Hafren'))

[Package cheddar version 0.1-636 Index]