community_scenarios: Generate scenarios for site by species matrices

community_scenariosR Documentation

Generate scenarios for site by species matrices

Description

Generate scenarios for site by species matrices

Usage

community_random(rn, mc, prevalence = 0.25, allow_empty_sites = TRUE)

community_equilibrium(rn, mc)

Arguments

rn

A river_network()

mc

A metacommunity()

prevalence

A vector of length 1 or length(mc[['species']]), what proportion of sites should be occupied on average by each species.

allow_empty_sites

Logical, if FALSE then empty sites will be filled with a single species at random; this may result in slight departures from the desired prevalence.

Details

community_random will ensure that all sites have at least one species. If many species have low prevalence, it may be that the initial random draw produces many zero-richness sites, in which case one species will be selected at random for each of these sites. This can have the side effect that the prevalences in the end do not match the desired prevalence very closely.

community_equilibrium simply places species at all sites where they are expected to be present at equilibrium, in the absence of competition (i.e., the fundamental niche is positive).

Value

A site by species matrix, with sites taken from rc and species from mc

Examples

Q = rep(1, 4)
adj = matrix(0, nrow = 4, ncol = 4)
adj[1,2] = adj[2,3] = adj[4,3] = 1
rn = river_network(adj, Q)
st0=rep(0.4,nrow(adj))
state(rn, "resources") = st0
mc = metacommunity()
state(rn, "species") = community_random(rn, mc)
plot(rn, variable = "species")
state(rn, "species") = community_equilibrium(rn, mc)
plot(rn, variable = "species")

flee-group/flume documentation built on Jan. 29, 2024, 6:44 p.m.