get_falls: Check seasonal change point in a vector of data

Description Usage Arguments Details Value Author(s) Examples

View source: R/get_falls.R

Description

Takes a numeric vector, locates and returns the indices of a maximum number of n_v_shape points given a specified number of relative points (that are higher at both side of a v shape point).

Usage

1
get_falls(x, n_v_shape = 1, steps = 3, force_steps = TRUE)

Arguments

x

A numeric vector. in which to check the indices of the fall (v-like) shape points.

n_v_shape

Integer. The number of points at which x takes a v-like shape. Default to 1.

steps

Integer. The minimum number of points at either sides of each v-like point to be considered higher for it to qualify as v-like point. Default to 3

force_steps

Logical. Should steps argument be enforced on both side each v_shape point? This is related to v-like points at the beiggining and/or end. Default to TRUE

Details

The number of points at both side of a v-like point will determine the number of v-like points to be return when there are many candidates since the higher the steps argument, the less the number of final points to be returned. while get_falls () will increase step-wise the number of steps to get closer to the number of specified v-like points (n_v_shape), it cannot handle cases where there are 2 or more equal points located at a v shape. Called on - x, get_falls () will return the peaks instead of v-like points.

Value

A vector of lenght (n_v_shape), at most, containing the indices of v-like points

Author(s)

Issoufou Liman

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
dx11 <- c(1.30, 1.15,  1.50,  2.00,  2.01,  3.00, 3.20,  4.76,  3.50,  3.00,  2.40,  2.00,  1.50)
dx12 <-c(1.29, 1.1, 1.49, 1.99, 2, 3.1, 4.5, 4, 2.8, 2.5, 2.3, 1.6, 1.59)
dx1 <- c(dx11, dx12)
## checking existing v-like shape
v_pts <- get_falls (dx1, n_v_shape = 1, steps = 3)
## ploting the v_pts in red
plot(dx1, col=ifelse(dx1==dx1[v_pts], 'red', 'black'),
pch=ifelse(dx1==dx1[v_pts], 19, 1), type = 'o')
## checking non existing v-like shape
get_falls (dx11, n_v_shape = 1, steps = 3)
get_falls (dx12, n_v_shape = 1, steps = 3)

Issoufou-Liman/growingSeason documentation built on Jan. 23, 2020, 3:43 a.m.