CollectionApply: Collection apply

View source: R/community_collection.R

CollectionApplyR Documentation

Collection apply

Description

Apply a function to every Community in a CommunityCollection. Works the same as lapply but returns a CommunityCollection rather than a list.

Usage

CollectionApply(collection, f, ...)

Arguments

collection

an object of class CommunityCollection.

f

a function to be applied to each Community.

...

optional arguments passed to f.

Value

A new object of class CommunityCollection.

Author(s)

Lawrence Hudson

See Also

CommunityCollection, lapply

Examples

data(pHWebs)

# Remove isolated nodes from each community
CollectionCPS(pHWebs, 'FractionIsolatedNodes')
pHWebs.no.iso <- CollectionApply(pHWebs, RemoveIsolatedNodes)
CollectionCPS(pHWebs.no.iso, 'FractionIsolatedNodes')


# Remove cannibalistic links from each community
sapply(pHWebs, function(community) length(Cannibals(community)))
pHWebs.no.can <- CollectionApply(pHWebs, RemoveCannibalisticLinks)
sapply(pHWebs.no.can, function(community) length(Cannibals(community)))


# Order the nodes each community by body mass
head(CollectionNPS(pHWebs))
pHWebs.by.M <- CollectionApply(pHWebs, OrderCommunity, 'M')
head(CollectionNPS(pHWebs.by.M))

quicklizard99/cheddar documentation built on Aug. 25, 2022, 5:01 a.m.