Skip to contents

Takes the mean of the previous and next value for each outlier observation, and replaces the outlier value with this mean value. Should be used with the find_outliers() function.

Usage

correct_outliers(x, col)

Arguments

x

A data.frame with the data including the .outlier column

col

The column to correct outliers from

Value

Returns a modified version of the input data.frame

Examples

silk_data1 |>
  find_outliers("y", group_col = "group") |>
  correct_outliers(col = "y") |>
  head()
#>   time         y   group  .median     .mad .outlier
#> 1    1  8.584244 series1 8.065949 2.713192    FALSE
#> 2    2  9.159694 series1 8.065949 2.713192    FALSE
#> 3    3  9.717704 series1 8.065949 2.713192    FALSE
#> 4    4 10.249923 series1 8.065949 2.713192    FALSE
#> 5    5 10.748432 series1 8.065949 2.713192    FALSE
#> 6    6 11.205878 series1 8.065949 2.713192    FALSE