Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

getPeakTrough

Identify peak or trough on curve


Description

Given vectors x and y, returns their values at the peak or trough of the smooth (e.g. cubic spline) curve y ~ x.

Usage

getPeakTrough(x, y = NULL, peak = TRUE, takeoff = FALSE)

getPeak(x, y = NULL, peak = TRUE, takeoff = FALSE)

getTrough(x, y = NULL, peak = FALSE, takeoff = FALSE)

getTakeoff(x, y = NULL, peak = FALSE, takeoff = TRUE)

Arguments

x

vector.

y

vector.

peak

logical determining whether peak or trough is returned.

takeoff

logical determining whether, if peak is FALSE, the trough is takeoff.

Details

Optionally the trough can be specified as takeoff, which is defined for a growth velocity curve as the lowest velocity before the pubertal peak, and if there is no peak then there is by definition no takeoff.

Value

A length-2 vector containing the values of x and y at the peak or trough. If none are identified NA's are returned.

Author(s)

Examples

## create mean height velocity curve
data(heights)
m1 <- sitar(age, height, id, heights, 4)
## plot velocity curve
plot(m1, 'v')
## mark peak, trough and takeoff
xy <- plot_v(m1)
points(t(getPeak(xy)), pch=17)
points(t(getTrough(xy)), pch=25, col=2, bg=2)
points(t(getTakeoff(xy)), pch=25, col=3, bg=3)

sitar

Super Imposition by Translation and Rotation Growth Curve Analysis

v1.2.0
GPL (>= 2)
Authors
Tim Cole [aut, cre] (<https://orcid.org/0000-0001-5711-8200>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.