View source: R/trajectoryPlots.R
| trajectoryPlot | R Documentation |
Set of plotting functions for Ecological Trajectory Analysis:
trajectoryPCoA(
x,
traj.colors = NULL,
axes = c(1, 2),
survey.labels = FALSE,
time.labels = FALSE,
...
)
trajectoryPlot(
coords,
sites,
surveys = NULL,
times = NULL,
traj.colors = NULL,
axes = c(1, 2),
survey.labels = FALSE,
time.labels = FALSE,
...
)
x |
An object of class |
traj.colors |
A vector of colors (one per site). If |
axes |
The pair of principal coordinates to be plotted. |
survey.labels |
A boolean flag to indicate whether surveys should be added as text next to arrow endpoints |
time.labels |
A boolean flag to indicate whether times should be added as text next to arrow endpoints |
... |
Additional parameters for function |
coords |
A data.frame or matrix where rows are ecological states and columns are coordinates in an arbitrary space |
sites |
A vector indicating the site corresponding to each ecological state. |
surveys |
A vector indicating the survey corresponding to each ecological state (only necessary when surveys are not in order). |
times |
A numeric vector indicating survey times. |
Function trajectoryPCoA performs principal coordinates analysis (cmdscale) and draws trajectories in the ordination scatterplot.
Function trajectoryPlot draws trajectories in a scatter plot corresponding to the input coordinates.
Function trajectoryPCoA returns the result of calling cmdscale.
Miquel De Cáceres, CREAF
Anthony Sturbois, Vivarmor nature, Réserve Naturelle nationale de la Baie de Saint-Brieuc
De Cáceres M, Coll L, Legendre P, Allen RB, Wiser SK, Fortin MJ, Condit R & Hubbell S. (2019). Trajectory analysis in community ecology. Ecological Monographs 89, e01350.
trajectoryMetrics, transformTrajectories, cmdscale, cyclePCoA
#Description of sites and surveys
sites <- c("1","1","1","2","2","2")
surveys <- c(1,2,3,1,2,3)
#Raw data table
xy<-matrix(0, nrow=6, ncol=2)
xy[2,2]<-1
xy[3,2]<-2
xy[4:6,1] <- 0.5
xy[4:6,2] <- xy[1:3,2]
xy[6,1]<-1
#Define trajectory data
x <- defineTrajectories(dist(xy), sites, surveys)
#Draw trajectories using original coordinates
trajectoryPlot(xy, sites, surveys,
traj.colors = c("black","red"), lwd = 2)
#Draw trajectories in a PCoA
trajectoryPCoA(x,
traj.colors = c("black","red"), lwd = 2)
#Should give the same results if surveys are not in order
#(here we switch surveys for site 2)
temp <- xy[5,]
xy[5,] <- xy[6,]
xy[6,] <- temp
surveys[5] <- 3
surveys[6] <- 2
trajectoryPlot(xy, sites, surveys,
traj.colors = c("black","red"), lwd = 2)
x <- defineTrajectories(dist(xy), sites, surveys)
trajectoryPCoA(x,
traj.colors = c("black","red"), lwd = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.