find_step: Find Step

Description Usage Arguments Value Examples

View source: R/find_step.R

Description

This function tries to use convolution to find steps in data. It returns candidates to remove in a vector.

Usage

1
find_step(x, tolerance, kernel_size = 3)

Arguments

x

target numeric vector

tolerance

integer, threshold distance for step detection after convolution

kernel_size

integer, kernel size of the convolution window (by default 3).

Value

vector of positions of 'x' where the step is predicted.

Examples

1
2
3
4
5
6
x <- c(rep(1,20), rep(50, 20), rep(1, 20))
candidate_10 <- find_step(x, tolerance = 10)
plot(x, type='l')
points(candidate_10, x[candidate_10])
# If tolerance is increased, step is not detected.
candidate_50 <- find_step(x, tolerance = 50)

matiasandina/stepfinder documentation built on Oct. 25, 2019, 9:24 a.m.