plotResponse | R Documentation |
This function plots the relationships between the virtual species and the environmental variables.
It requires either the output from generateSpFromFun
, generateSpFromPCA
,
generateRandomSp
,
or a manually defined set of environmental variables and response functions.
plotResponse(
x,
parameters = NULL,
approach = NULL,
rescale = NULL,
axes.to.plot = NULL,
no.plot.reset = FALSE,
rescale.each.response = NULL,
...
)
x |
the output from |
parameters |
in case of manually defined response functions, a list containing the associated parameters. See details. |
approach |
in case of manually defined response functions, the chosen
approach: either |
rescale |
|
axes.to.plot |
a vector of 2 values listing the two axes of the PCA to plot. Only useful for a PCA species. |
no.plot.reset |
|
rescale.each.response |
|
... |
further arguments to be passed to |
If you provide the output from generateSpFromFun
, generateSpFromPCA
or
generateRandomSp
then the function will automatically make the appropriate plots.
Otherwise, you can provide a raster layer/stack of environmental variables to
x
and a list of functions to parameters
to perform the plot.
In that case, you have to specify the approach
: "reponse"
or
"PCA"
:
if approach = "response"
: Provide to parameters
a
list
exactly as defined in generateSpFromFun
:
list(
var1 = list(fun = 'fun1', args = list(arg1 = ..., arg2 = ..., etc.)),
var2 = list(fun = 'fun2', args = list(arg1 = ..., arg2 = ..., etc.)))
if approach = "PCA"
: Provide to parameters
a
list
containing the following elements:
pca
: a dudi.pca
object computed with
dudi.pca
means
: a vector containing two numeric values. Will be used to define
the means of the gaussian response functions to the axes of the PCA.
sds
a vector containing two numeric values. Will be used to define
the standard deviations of the gaussian response functions to the axes of
the PCA.
Boris Leroy leroy.boris@gmail.com
with help from C. N. Meynard, C. Bellard & F. Courchamp
# Create an example stack with four environmental variables
a <- matrix(rep(dnorm(1:100, 50, sd = 25)),
nrow = 100, ncol = 100, byrow = TRUE)
env <- c(rast(a * dnorm(1:100, 50, sd = 25)),
rast(a * 1:100),
rast(a * logisticFun(1:100, alpha = 10, beta = 70)),
rast(t(a)))
names(env) <- c("var1", "var2", "var3", "var4")
# Per-variable response approach:
parameters <- formatFunctions(var1 = c(fun = 'dnorm', mean = 0.00012,
sd = 0.0001),
var2 = c(fun = 'linearFun', a = 1, b = 0),
var3 = c(fun = 'quadraticFun', a = -20, b = 0.2,
c = 0),
var4 = c(fun = 'logisticFun', alpha = -0.001,
beta = 0.002))
sp1 <- generateSpFromFun(env, parameters, plot = TRUE)
plotResponse(sp1)
# PCA approach:
sp2 <- generateSpFromPCA(env, plot = FALSE)
par(mfrow = c(1, 1))
plotResponse(sp2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.