plotResponse: Visualise the response of the virtual species to...

Description Usage Arguments Details Author(s) Examples

View source: R/plotResponse.R

Description

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.

Usage

1
2
plotResponse(x, parameters = NULL, approach = NULL, rescale = TRUE,
  axes.to.plot = NULL, no.plot.reset = FALSE, ...)

Arguments

x

the output from generateSpFromFun, generateSpFromPCA, generateRandomSp, or a raster layer/stack of environmental variables (see details for the latter).

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 "response" for a per-variable response approach, or "pca" for a PCA approach.

rescale

TRUE or FALSE. If TRUE, individual response plots are rescaled between 0 and 1.

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

TRUE or FALSE. If TRUE, the plot parameters will be reset to their initial state after the response has been plotted.

...

further arguments to be passed to plot. See plot and par.

Details

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 specifiy the approach: "reponse" or "PCA":

Author(s)

Boris Leroy [email protected]

with help from C. N. Meynard, C. Bellard & F. Courchamp

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Create an example stack with four environmental variables
a <- matrix(rep(dnorm(1:100, 50, sd = 25)), 
            nrow = 100, ncol = 100, byrow = TRUE)
env <- stack(raster(a * dnorm(1:100, 50, sd = 25)),
             raster(a * 1:100),
             raster(a * logisticFun(1:100, alpha = 10, beta = 70)),
             raster(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)

virtualspecies documentation built on July 4, 2017, 9:31 a.m.