LinksOfPM: Links to predation matrices and predation matrices to links

Description Usage Arguments Details Value Author(s) Examples

Description

RandomLinks.

Usage

1
2
PMOfLinks(links, S)
LinksOfPM(matrices)

Arguments

links

a list of matrices with columns named ‘resource’ and ‘consumer’ with the values either $0$ and $1$.

S

the number of species in the pool from which ‘links’ were drawn

matrices

a list of square matrix objects with the values either $0$ and $1$.

Details

PMOfLinks converts the ‘list of links’ form to 'predation matrix' form, a square matrix with ‘S’ rows and ‘S’ columns.

Value

Either a list of square matrices or a list of matrices with columns named ‘resource’ and ‘consumer’.

Author(s)

Lawrence Hudson

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Generate some links
links <- RandomLinks(n=10, S=10, C=0.15)
links[[1]]

# Get predation matrices
pm <- PMOfLinks(links, 10)
pm[[1]]

# Get lists of links
reconstructed.links <- LinksOfPM(pm)

# Randomly generated links will have an arbitraty order - order by consumer,
# resource for the purposes of comparison
links <- lapply(links, function(l) l[order(l[,'consumer'], l[,'resource']),])

# Should be TRUE
all.equal(links, reconstructed.links)

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