Collection apply

Share:

Description

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

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
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))

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.