gg_envfit: Vegan envfit plot

View source: R/gg_envfit.R

gg_envfitR Documentation

Vegan envfit plot

Description

Fits environmental parameters to an ordination plot of sites and plots them as arrows or centroid labels.

Usage

gg_envfit(
  ord,
  env,
  groups = NA,
  scaling = 1,
  choices = c(1, 2),
  perm = 999,
  alpha = 0.05,
  angle = 20,
  len = 0.5,
  unit = "cm",
  arrow.col = "red",
  pt.size = 3,
  show_factors = FALSE,
  plot = TRUE
)

Arguments

ord

An ordination object.

env

A data frame of environmental parameters.

groups

A vector of groups.

scaling

Scaling value for plot.

choices

Axes to plot.

perm

Number of permutations.

alpha

Maximum alpha value to be included in plot.

angle

Angle of arrow tips.

len

Arrow tip length.

unit

Unit for length ("cm", "in")

arrow.col

Arrow color.

pt.size

Symbol size.

show_factors

A logical for including factors on the plot; defaults to FALSE.

plot

A logical for plotting; defaults to TRUE.

Details

Vegan's envfit function fits environmental variables to an ordination. If the variable is numeric, an arrow is fitted to the ordination plot indicating the direction in which that variable increases. If the variable is a factor (or character vector), vegan's envfit plotting function treats levels of the factor as groups and adds labels for the factor's level to the ordination plot at each group's centroid center. This behavior is now enabled in gg_envfit() if show_factors is set to TRUE.

Value

Silently returns the plot and data frames used for the plotting if the fit of any variable is significant at alpha. Otherwise returns a message that no variable is significant.

Note

In order for the arrow tips to be labeled with the names of the variables, they must be supplied as a matrix or data frame. If a single variable is supplied as a vector, the arrow tip will be labeled with "1". A way-around is to convert the vector to a data frame with the column named for the variable.

Examples

data("varespec")
data("varechem")
vare.dist <- vegdist(varespec)
vare.mds <- monoMDS(vare.dist)
gg_envfit(ord=vare.mds, env=varechem)

data("dune")
data("dune.env")
dune.dist <- vegdist(dune)
dune.mds <- monoMDS(dune.dist)
# A1 supplied as a vector
gg_envfit(dune.mds, env=dune.env$A1, groups=dune.env$Management)
# A1 supplied as a data frame
A1 <- as.data.frame(dune.env$A1)
colnames(A1) <- "A1"
gg_envfit(dune.mds, env=A1, groups=dune.env$Management)


jfq3/ggordiplots documentation built on Oct. 27, 2024, 11:01 p.m.