PredationMatrixToLinks | R Documentation |
A function that converts a predation matrix to a
data.frame
with the columns ‘resource’ and ‘consumer’.
PredationMatrixToLinks(pm, link.property=NULL)
pm |
a |
link.property |
either |
Returns a data.frame
of trophic links contained within
pm
. Non-zero and non-NA
values indicate a trophic link between
a resource (row) and consumer (column). pm
should have both row names
and column names. The returned data.frame
will contain the columns
‘resource’ and ‘consumer’. If pm
contains quantitative information
such as diet fractions or number of observations then you can set
link.property
to the name of the quantity and the returned
data.frame
will include a column with that name, that contains link
strength values extracted from pm
.
If you have existing food-web data in predation-matrix form then this function can help to import your data in to Cheddar.
A data.frame
Lawrence Hudson
Community
,
PredationMatrix
,
TLPS
data(TL84) links <- PredationMatrixToLinks(PredationMatrix(TL84)) identical(links, TLPS(TL84)) # TRUE # Create a Cheddar community from an existing square predation matrix node <- c('Leaf', 'Caterpillar', 'Bluetit') pm <- matrix( c(0, 1, 0, 0, 0, 1, 0, 0, 0), ncol=3, byrow=TRUE, dimnames=list(node, node)) community1 <- Community(nodes=data.frame(node=node), trophic.links=PredationMatrixToLinks(pm), properties=list(title='Test community')) TLPS(community1) # The same set of trophic links could be represented by a non-square predation # matrix pm <- matrix( c(1, 0, 0, 1), ncol=2, byrow=TRUE, dimnames=list(node[1:2], node[2:3])) community2 <- Community(nodes=data.frame(node=node), trophic.links=PredationMatrixToLinks(pm), properties=list(title='Test community')) TLPS(community2) all.equal(community1, community2) # TRUE # Extract quantitative information node <- c('Leaf 1', 'Leaf 2', 'Caterpillar 1', 'Caterpillar 2') pm <- matrix( c(0, 0, 0.4, 0.8, 0, 0, 0.6, 0.2, 0, 0, 0, 0, 0, 0, 0, 0), ncol=4, byrow=TRUE, dimnames=list(node, node)) # A data.frame that has a column called diet.fraction PredationMatrixToLinks(pm, link.property='diet.fraction')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.