ordin_legend: Create legend for base vegan ordination plots

Description Usage Arguments Value Examples

View source: R/ordin_legend.R

Description

This function uses a vegan ordination object (e.g. from metaMDS) and a valid metadata table with Factor1 and Factor2 and is meant to be used in conjunction with CMETNGS::ordin_annotate.

Usage

1
ordin_legend(metadata, location = "bottomleft")

Arguments

metadata

a valid CMET metadata object, containing minimally the sample names, Factor1 and Factor2.

location

where to put the legend on the plot, defaults to "bottomleft"

Value

A list with the colvector and pchvector

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Short example

# Load precomputed example data
library(vegan)
data(dune)
dune.dis <- vegdist(wisconsin(dune))
dune.mds <- cmdscale(dune.dis, eig = TRUE)
#create completely made-up metadata for dune
dune.md <- data.frame(Factor1=c(rep("Dune1",nrow(dune)/2),
rep("Dune2",nrow(dune)/2)),Factor2=c(rep("Grass",7),rep("Shrub",7),
rep("Tree",6)))
veclist <- ordin_annotate(dune.mds,dune.md)
dune.mds$species <- wascores(dune.mds$points, dune, expand = TRUE)
pl <- ordiplot(dune.mds, type = "none")
points(pl, "sites", pch=veclist$pchvect, col=veclist$colvect, bg="yellow")
ordipointlabel(dune.mds,display = "sites",add=TRUE)
ordin_legend(dune.md,location="topright")

CMET-UGent/CMETNGS documentation built on Dec. 12, 2020, 8:22 a.m.