CommunityFactory: Community factory

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Community factory.

Usage

1
2
3
4
CommunityFactory(S, nodes, generator, n=1, 
                 accept=NULL, energetically.feasible=TRUE, 
                 trace.progress=FALSE, validate=TRUE,
                 properties=NULL, ...)

Arguments

S

number of nodes in the generated communities.

nodes

either a vector of node names or a data.frame of node properties that satisfies the conditions nodes of Community.

generator

function used to generate sets of trophic links.

n

number of communities to generate.

accept

either NULL or a function that takes a community as its only argument and returns a logical.

energetically.feasible

if TRUE, communities that are not energetically feasible according to Cheddar's PreyAveragedTrophicLevel function are discarded.

trace.progress

if TRUE then feedback is printed as the function runs.

validate

if 'TRUE', created communities are validated using the checks provided by Cheddar's Community function.

properties

either NULL or a list of community-level properties.

...

.

Details

Either ‘S’ or ‘nodes’ should be provided - no need to provide both.

Value

A list of ‘n’ Community objects.

Author(s)

Lawrence Hudson

See Also

Community, PreyAveragedTrophicLevel IsIsolatedNode, IsolatedNodes IsBasalNode, BasalNodes

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Example 1
# Use the niche model to create 12 communities containing 25 species with a
# directed connectance close to 0.15. 
communities <- CommunityFactory(S=25, n=12, generator=NicheModelLinks, C=0.15)

# Communities are named 'Artificial community 1'..'Artificial community n'
names(communities)

# Each has 25 nodes
sapply(communities, NumberOfNodes)

# Each has a C close to 0.15
sapply(communities, DirectedConnectance)
hist(sapply(communities, DirectedConnectance))

# Plot nodes stacked vertically by trophic level
plot(communities, ncol=4)

# At least one community will have a non-zero number of isolated nodes
sapply(communities, function(c) return(length(IsolatedNodes(c))))


# Example 2
# Use the accept argument to ensure that the communities have no isolated
# nodes, using Cheddar' IsIsolatedNode function
communities <- CommunityFactory(S=25,
                                n=12,
                                generator=NicheModelLinks,
                                C=0.15,
                                accept=function(c) 0==sum(IsIsolatedNode(c)))

# All zero
sapply(communities, function(c) return(length(IsolatedNodes(c))))


# Example 3
# Guarantee that communities have no isolated nodes and exactly 5 basal nodes -
# use Cheddar's IsBasalNode function for this; also get CommunityFactory to
# trace its progress.
communities <- CommunityFactory(S=25,
                                n=12,
                                generator=NicheModelLinks,
                                C=0.15,
                                accept=function(c) 0==sum(IsIsolatedNode(c)) &&
                                                   5==sum(IsBasalNode(c)),
                                trace.progress=TRUE)

# No community has isolated nodes
all(0==sapply(communities, function(c) return(length(IsolatedNodes(c)))))

# All communities have five basal nodes
all(5==sapply(communities, function(c) return(length(BasalNodes(c)))))

quicklizard99/Basingstoke documentation built on May 26, 2019, 1:31 p.m.