Description Usage Arguments Details Value See Also Examples
Finds discrete cycles of wave-like data using critical points (peaks and troughs).
1 |
x |
numeric; x position |
y |
numeric; y position |
start |
character; where the cycles should start either 'peak' or ‘trough’. See Details. |
... |
additional arguments to be passed to |
If "'start='peak'", the cycles start at critical points with high values, If "'start='trough'", cycles start at critical points with low values.
A a data table including the following:
cyc
: The cycle number.
pos
: the position/index values of the x data (not the x values themselves).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | library(ggplot2)
n <- 200
d <- data.frame(
x <- sort(runif(n)),
y <- exp(-0.2 * sin(10*pi*x)) + rnorm(n, sd=0.05)
)
#start at peaks
c <- cyclize(d$x,d$y)
d$cyc <- c$cyc
qplot(d=d,x,y,col=as.factor(cyc))
#start at troughs
c <- cyclize(d$x,d$y,start="trough")
d$cyc <- c$cyc
qplot(data=d,x,y,col=as.factor(cyc))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.