cyclize: Calculate waveform cycles

View source: R/kin.2d.R

cyclizeR Documentation

Calculate waveform cycles

Description

Finds discrete cycles of wave-like data using critical points (peaks and troughs).

Usage

cyclize(x, y, start = "peak", ...)

Arguments

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 features

Details

If "'start='peak'", the cycles start at critical points with high values, If "'start='trough'", cycles start at critical points with low values.

Value

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).

See Also

features

Examples

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))


ckenaley/trackter documentation built on Jan. 9, 2025, 10:45 p.m.