View source: R/community_collection.R
CollectionApply | R Documentation |
Apply a function to every Community
in a
CommunityCollection
. Works the same as lapply
but returns a
CommunityCollection
rather than a list
.
CollectionApply(collection, f, ...)
collection |
an object of class |
f |
a function to be applied to each |
... |
optional arguments passed to |
A new object of class CommunityCollection
.
Lawrence Hudson
CommunityCollection
, lapply
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.