Description Usage Arguments Details Examples
A utility function to enable users to create bespoke transition
functions (transfun
objects) for use in transition
s.
1 | as.transfun(fun, param, type = c("probability", "rate", "dispersal"))
|
fun |
an R function describing the transition. This must take only one
argument: |
param |
a named list of the parameters of |
type |
what type of transition this function represents, a probability or a rate |
fun
must take only one argument, landscape
, an object
of class landscape
. landscape
objects contain three
elements which may be used in the function: population
, a dataframe
giving the number of individuals of each stage (columns) in each patch
(rows); area
; a numeric vector giving the area of each patch in
square kilometres; and features
, a dataframe containing
miscellaneous features (columns) of each habitat patch (rows), such as
measures of patch quality or environmental variables. See examples for an
illustration of how to these objects. Parameters of the transfun should be
passed to as.transfun
as a named list. These can then be used in
fun
by accessing them from this list. Note that param
isn't
an argument to fun
, instead it's modified directly in the function's
envirnment (because reasons).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # a very simple (and unnecessary, see ?p) transfun
fun <- function(landscape) param$prob
prob <- as.transfun(fun, param = c(prob = 0.3), type = 'probability')
# a density-dependent probability
dd_fun <- function (landscape) {
adult_density <- population(landscape, 'adult') / area(landscape)
param$p * exp(- adult_density/param$range)
}
dd_prob <- as.transfun(dd_fun,
param = list(p = 0.8,
range = 10),
type = 'probability')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.