View source: R/formatFunctions.R
formatFunctions | R Documentation |
generateSpFromFun
This function is a helper function to simplify the formatting of functions
for generateSpFromFun
formatFunctions(x = NULL, rescale = TRUE, ...)
x |
NULL or a |
rescale |
|
... |
the parameters to be formatted. See details. |
This function formats the parameters
argument of generateSpFromFun
.
For each environmental variable, provide a vector containing the function name, and its arguments.
For example, assume we want to generate a species responding to two environmental variables bio1 and bio2.
The response to bio1 is a normal response (dnorm
), of mean 1 and standard deviation 0.5.
The response to bio2 is a linear response (linearFun
), of slope (a) 2 and intercept (b) 5.
The correct writing is:
formatFunctions(
bio1 = c(fun = "dnorm", mean = 1, sd = 0.5),
bio2 = c(fun = "linearFun", a = 2, b = 5))
Do not use 'x' as a name for your environmental variables.
Boris Leroy leroy.boris@gmail.com
with help from C. N. Meynard, C. Bellard & F. Courchamp
my.parameters <- formatFunctions(variable1 = c(fun = 'dnorm',
mean = 0.00012, sd = 0.0001),
variable2 = c(fun = 'linearFun', a = 1, b = 0))
my.parameters <- formatFunctions(bio1 = c(fun = "logisticFun",
alpha = -12.7, beta = 68),
bio2 = c(fun = "linearFun",
a = -0.03, b = 191.2),
bio3 = c(fun = "dnorm",
mean = 86.4, sd = 19.1),
bio4 = c(fun = "logisticFun",
alpha = 2198.5, beta = 11381.4))
## Not run:
# An example using worldclim data
bio1.4 <- getData('worldclim', var='bio', res=10)[[1:4]]
my.parameters <- formatFunctions(x = bio1.4,
bio1 = c(fun = "logisticFun",
alpha = -12.7, beta = 68),
bio2 = c(fun = "linearFun",
a = -0.03, b = 191.2),
bio3 = c(fun = "dnorm",
mean = 86.4, sd = 19.1),
bio4 = c(fun = "logisticFun",
alpha = 2198.5, beta = 11381.4))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.