#First build a toy dataset with:
#The sampling times of the time series
timesToy <- 0:30
#The duration of the cycles (i.e. the periodicity of the time series)
cycleDurationToy <- 10
#The sites sampled (only one named "A")
sitesToy <- rep(c("A"),length(timesToy))
#And prepare a trend term
trend <- 0.05
#Build cyclical data (note that we apply the trend only to x):
x <- sin((timesToy*2*pi)/cycleDurationToy)+trend*timesToy
y <- cos((timesToy*2*pi)/cycleDurationToy)
matToy <- cbind(x,y)
#And express it as distances:
dToy <- dist(matToy)
#Make it an object of class trajectory:
cyclicalTrajToy <- defineTrajectories(d = dToy,
sites = sitesToy,
times = timesToy)
#And extract the cycles and fixed date trajectories:
cyclesToy <- extractCycles(x = cyclicalTrajToy,
cycleDuration = cycleDurationToy)
fdTrajToy <- extractFixedDateTrajectories(x = cyclicalTrajToy,
cycleDuration = cycleDurationToy)
#CETA plotting functions:
cyclePCoA(cyclesToy)
fixedDateTrajectoryPCoA(fdTrajToy)
#After centering of cycles, set parameter centered to TRUE in cyclePCoA():
cent_cyclesToy <- centerTrajectories(cyclesToy)
cyclePCoA(cent_cyclesToy, centered = TRUE)
Run the code above in your browser using DataLab