View source: R/defineTrajectories.R
defineTrajectories | R Documentation |
Defines data structures for trajectory analysis
defineTrajectories(d, sites, surveys = NULL, times = NULL)
d |
A symmetric |
sites |
A character vector indicating the ecological entity (site, individual, community) corresponding to each ecological state (other types are converted to character). |
surveys |
An integer vector indicating the survey corresponding to each ecological state (only necessary when surveys are not in order). |
times |
A numeric vector indicating survey times (if missing, survey times are made equal to surveys). |
An object (list) of class trajectories
with the following elements:
d
: An object of class dist
containing relationships between ecological states
metadata
: A data frame describing trajectory states, with the following columns:
sites
: A character vector indicating the ecological entity corresponding to each ecological state.
surveys
: An integer vector indicating the survey corresponding to each ecological state.
times
: A numeric vector indicating survey times.
subsetTrajectories
#Description of entities (sites) and surveys
entities <- 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
d <- dist(xy)
# Defines trajectories
x <- defineTrajectories(d, entities, surveys)
x
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.