Defines data structures for trajectory analysis
Arguments
- d
A symmetric
matrix
or an object of classdist
containing the distance values between pairs of ecosystem states..- sites
A character vector indicating the site corresponding to each ecosystem state (other types are converted to character).
- surveys
An integer vector indicating the survey corresponding to each ecosystem 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).
Value
An object (list) of class trajectories
with the following elements:
d
: An object of classdist
containing relationships between ecosystem statesmetadata
: A dataframe describing trajectory states, with the following columns:sites
: A character vector indicating the site corresponding to each ecosystem state.surveys
: An integer vector indicating the survey corresponding to each ecosystem state.times
: A numeric vector indicating survey times.
Examples
#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
d <- dist(xy)
# Defines trajectories
x <- defineTrajectories(d, sites, surveys)
x
#> $d
#> 1 2 3 4 5
#> 2 1.000000
#> 3 2.000000 1.000000
#> 4 0.500000 1.118034 2.061553
#> 5 1.118034 0.500000 1.118034 1.000000
#> 6 2.236068 1.414214 1.000000 2.061553 1.118034
#>
#> $metadata
#> sites surveys times
#> 1 1 1 1
#> 2 1 2 2
#> 3 1 3 3
#> 4 2 1 1
#> 5 2 2 2
#> 6 2 3 3
#>
#> attr(,"class")
#> [1] "trajectories" "list"